The Tamiya double gearbox can be controlled using the digital logic signals from the Arduino's 5v output. However there was some concern about powering the motors directly from the output ports as they draw a lot of current and the Arduino is going to be used to drive multiple systems.
In order to overcome this problem a H- Bridge motor driver (in this case a L293D chip) was used. This enabled the use the logic signals from the Arduino while powering the motors from an external power source.
Breadboard Layout
The motors seen in the diagram above are connected to the left and right sides of the Tamiya double gearbox in order to drive the tracks on the respective sides of the robot. The power source is independent from the Arduino power source and is used to provide power to the two motors, the two servos and the laser. In this case 4 AA batteries are used to provide 6V. It is yet to be tested how long these will power the robot for.
One issue noticed was that if the external power was removed or turned off before the logic signals the motors would continue to attempt to run using the power from the logic circuit. So it should be ensured the arduino isnt sending motor signals without power being supplied to pin 8.
IC Circuit diagram
As seen in the above diagram channels 1 and 2 are used for motor 1 which controls the left track. Therefore in order to make the left track go forward pin 2 (channel 1 input) is set high and pin 7 is set low. Similarly if pin 7 is set high and pin 2 set low the motor will reverse. If the two pins are the same, both high or both low then the motor doesn't move. Channels 3 and 4 are used in the same way to control motor 2 controlling the track on the right side of the robot.
The Arduino code to test the motors was therefore extremely simple and just consisted of setting each of the 4 pins either high or low for 1.5 seconds depending on which direction the user wants the robot to move, in between each test the robot is set to stop for 1.5 seconds before moving onto the next instruction.
void setup() {
Serial.begin(9600);
// pin 9 - brown
// pin 10 - blue
// pin 11 - white
// pin 12 - red
}
void loop() {
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
delay(1500);
digitalWrite(9,HIGH);//stop
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
delay(1500);
//Back
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
delay(1500);
//stop
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
delay(1500);
//left
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
delay(1500);
//stop
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
delay(1500);
//right
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
delay(1500);
//stop
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
delay(1500);
}
A video showing this test is shown below.