BrainGamer Intro

BrainGamer Intro

The provided driver allows users to control the BrainGamer controller without needing to understand advanced details.

Software driver (library) is provided to start using BrainGamer with minimal needed knowledge. Future gaming lessons cover details on using the driver.

The driver provided below needs to be copied to to your BrainGamer projects.

///////////////////////////
///  BrainGamer Driver  ///
///////////////////////////
class BrainGamer
{
    DUELinkController BrainPad;
    public BrainGamer(DUELinkController brainpad){
        BrainPad = brainpad;
    }
    public int RockerX(){
        var x = BrainPad.Analog.Read(4);
        return (x);
    }
    public int RockerY(){
        var y = BrainPad.Analog.Read(3);
        return (y);
    }
    public void Vibrator(bool enable){
        BrainPad.Digital.Write(8, !enable);
    }
    public bool ButtonUp(){
        return !BrainPad.Digital.Read(14, BrainPad.Pin.PullUp);
    }
    public bool ButtonDown(){
        return !BrainPad.Digital.Read(15, BrainPad.Pin.PullUp);
    }
    public bool ButtonLeft(){
        return !BrainPad.Digital.Read(13, BrainPad.Pin.PullUp);
    }
    public bool ButtonRight(){
        return !BrainPad.Digital.Read(16, BrainPad.Pin.PullUp);
    }
}
#############################
###   BrainGamer Driver   ###
#############################
from DUELink.DUELinkController import DUELinkController
class BrainGamer:
    def __init__(self, brainpad:DUELinkController):
        self.BrainPad = brainpad
    def RocketX(self)-> int:
        x = self.BrainPad.Analog.Read(4)
        return x    
    def RockerY(self)-> int: 
        y = self.BrainPad.Analog.Read(3)
        return y
    ### Vibrator ###
    def Vibrator(self, enable: bool):
        self.BrainPad.Digital.Write(8, not enable)
        return
    ### Read Buttons ###
    def ButtonUp(self):
        u =  not self.BrainPad.Digital.Read(14,1)
        return u
    def ButtonDown(self):
        d =  not self.BrainPad.Digital.Read(15,1)
        return d
    def ButtonLeft(self):
        l = not self.BrainPad.Digital.Read(13,1)
        return l
    def ButtonRight(self):
        r = not self.BrainPad.Digital.Read(16,1)
        return r

Using the BrainGamer is now done easily.

var Gamer = new BrainGamer(BrainPad);
var x = Gamer.RockerX();
var y = Gamer.RockerY();
Gamer = BrainGamer(BrainPad)
x = Gamer.RockerX()
y = Gamer.RockerY()

What’s Next?

You are now ready to start making games with the BrainGamer. Start with making BrainGamer Pong game.

Content Licensing
Newsletter

Twitter Feed
Hot off the press!
November 24, 2023
November 20, 2023
November 15, 2023
November 15, 2023
November 9, 2023
November 9, 2023
October 31, 2023
October 24, 2023