Beginning Build of Robot with Magnevation Motor Driver




//Arduino Sketch
int switchPin = 7;
int potPin = 0;

int SpeedPinR = 9;
int SpeedPinL = 10;
int brakeRPin = 2;
int brakeLPin = 3;
int DirRPin = 4;
int DirLPin = 5;

void setup() {
pinMode(brakeRPin, OUTPUT);
pinMode(brakeLPin, OUTPUT);
pinMode(DirRPin, OUTPUT);
pinMode(DirLPin, OUTPUT);
pinMode(SpeedPinR, OUTPUT);
pinMode(SpeedPinL, OUTPUT);

pinMode(switchPin, INPUT_PULLUP);
void loop() {
//int speed = analogRead(potPin) / 4;
int speedR = 20;
int speedL = 40;
boolean brakeR = LOW;
boolean brakeL = LOW;
boolean reverseR = HIGH;
boolean reverseL = HIGH;
//boolean reverse = digitalRead(switchPin);

setMotorR(speedR, reverseR, brakeR);     //setMotor(Speed, Reverse, Brake):   reverse HIGH = forward, = LOW = backward :
setMotorL(speedL, reverseL, brakeL);     //setMotor(Speed, Reverse, Brake):   reverse HIGH = forward, = LOW = backward :

void setMotorR(int speedR, boolean reverseR, boolean brakeR) {
if (speedR > 255){speedR ==255;};
digitalWrite(brakeRPin, brakeR);        //HIGH brake = stop
analogWrite(SpeedPinR, speedR);      //PWM pin OOPIC 27/29
digitalWrite(DirRPin, reverseR);      //reverse = HIGH forward
void setMotorL(int speedL, boolean reverseL,  boolean brakeL) {
if (speedL > 255){speedL ==255;};
digitalWrite(brakeLPin, brakeL);        //HIGH brake = stop
analogWrite(SpeedPinL, speedL);      //PWM pin OOPIC 27/29
digitalWrite(DirLPin, ! reverseL);      //reverse = HIGH forward



Here’s a really really great source for circuits for personal use.

On of my favorite websites for electronics circuits is   You will find very good documented circuits that include a detailed explanation of how they work.  I think this archive can provide a great library of circuits to devise your own ideas from.  Or have fun building one as a project on the weekend.   Some are ardunio based, and others could be converted by you for use with your ardunio.