I used some longer wires to connect them up to the Arduino so they could move around a bit.
I wired up a second motor controller on the breadboard, same as the first one. I made a video of doing this, which you can see here
//left and right motors
int motorPinL = 9;
int motorPinR = 10;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pins as an output.
pinMode(motorPinL,OUTPUT);
pinMode(motorPinR,OUTPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
if (Serial.available() > 0)
{
char ch = Serial.read();
// press 'g' to go:
if (ch == 'g')
{ digitalWrite(motorPinL, HIGH);
digitalWrite(motorPinR, HIGH);
}
if (ch == 's')
// press 's' to stop:
{digitalWrite(motorPinL, LOW);
digitalWrite(motorPinR, LOW);
}
if (ch == 'r')
// press 'r' to run just one motor:
{ digitalWrite(motorPinL, LOW);
digitalWrite(motorPinR, HIGH);
}
if (ch == 'l')
// press 'l' to run the other motor:
{
digitalWrite(motorPinR, LOW);
digitalWrite(motorPinL, HIGH);}
}
}
This video shows the vehicle working:
All very well but now I need to look into how to make the vehicle more autonomous, so for example it can avoid obstacles.
No comments:
Post a Comment