Introduction: Make a Robot With Arduino for Beginners
Step 1: Materials Needed
- Tamiya Track and Wheel Set Assembly ($7.95 at Pololu)
- Tamiya 70168 Double Gearbox Kit ($9.25 at Pololu)
- L298N Dual H Bridge ($3.65 at Amazon and might be much lower at ebay)
- 4AA Battery Holder (used from broken electronics)
- 200mm Female and Male Jumper Cables ($2.60 at Amazon)
- Universal Tamiya plate ($7.77 at Amazon)
- Arduino Uno or its clone
Note: Universal Tamiya Plate is optional. That is you can use wood in place of it. But, for convince I've used the plate.
Step 2: Procedure
- Assemble the gear motor as described in the manual. For this project I've used 114.7:1 gear ratio
- Mount the double gear motor onto the Tamiya plate
- Connect the 6V battery holder (+) to the L298N +12V port and (-) to the GND using jumper cables
- Connect the arduino GND to the L298N GND
- Finally, connect the motors to the L298N two side output ports
- Follow my drawing for circuitry for further clarity
- Connect the pins of L298N to Arduino as the following:
Right side
Pin1 --------------------------------- 3 of Arduino (PMW pin)
Pin 2 --------------------------------- 6
Pin 3 --------------------------------- 4
Pin 4 --------------------------------- 13
Pin 5 --------------------------------- 12
Pin 6----------------------------------- 9 (PMW pin)
Note: Don't worry about the polarity of the motor connection because we can change it through the code
Step 3: Code
First of all, download the Arduino Software from their website. Then copy and paste the following code:
void setup(){ Serial.begin(9600); //right motor pinMode(3,OUTPUT); pinMode(6,OUTPUT); pinMode(4,OUTPUT);//pwm //left motor pinMode(13,OUTPUT); pinMode(12,OUTPUT); pinMode(9,OUTPUT);//pwm } void loop() { int Racerspeed=80; int ReverseSpeed=60; //forward digitalWrite(6,HIGH); delay(100); digitalWrite(4,LOW); analogWrite(3,Racerspeed);//right motor</p><p> digitalWrite(13,HIGH); delay(100); digitalWrite(12,LOW); analogWrite(9,Racerspeed);// left motor delay(4000); //reverse digitalWrite(6,LOW); delay(100); digitalWrite(4,HIGH); analogWrite(3,ReverseSpeed);</p><p> digitalWrite(13,LOW); delay(100); digitalWrite(12,HIGH); analogWrite(9,ReverseSpeed);// left motor</p><p> delay(5000);</p><p> //stop digitalWrite(6,LOW); delay(100); digitalWrite(4,LOW); analogWrite(3,0);// right motor</p><p> digitalWrite(13,LOW); delay(100); digitalWrite(12,LOW); analogWrite(9,0);// left motor</p><p> delay(5000); //turnleft digitalWrite(13,LOW); //changed this (7/12/2015) delay(100); digitalWrite(12,HIGH); analogWrite(9,30);// left motor</p><p> digitalWrite(6,HIGH); delay(100); digitalWrite(4,LOW); analogWrite(3,120);//right motor</p><p> delay(1000); }
Step 4: Future Updates
Yes! You saw it right there are more updates coming for this robot. Some of them are as follows:
1) Adding ON/OFF switch
2) Controlling it with IR remote
3) Adding distance sensor
Stay tuned, and happy making robots!
Any donations will be used for future projects, thank you!