Make a Robot With Arduino for Beginners

by saimouli in Circuits > Gadgets

6681 Views, 83 Favorites, 0 Comments

Make a Robot With Arduino for Beginners

11749689_10206888788399008_1969297955_n.jpg
11721949_10206888788599013_597057174_n.jpg
11739620_10206888788639014_2119514212_n.jpg
Arduino Robot



Materials Needed

Battery holder.jpg
Arduino Uno.jpg
L298N.jpg
Gearbox.jpg
Jumpers.jpg
Tamiya chasis kit.jpg
  1. Tamiya Track and Wheel Set Assembly ($7.95 at Pololu)
  2. Tamiya 70168 Double Gearbox Kit ($9.25 at Pololu)
  3. L298N Dual H Bridge ($3.65 at Amazon and might be much lower at ebay)
  4. 4AA Battery Holder (used from broken electronics)
  5. 200mm Female and Male Jumper Cables ($2.60 at Amazon)
  6. Universal Tamiya plate ($7.77 at Amazon)
  7. 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.

Procedure

11753858_10206890302716865_4266569_n.jpg
  1. Assemble the gear motor as described in the manual. For this project I've used 114.7:1 gear ratio
  2. Mount the double gear motor onto the Tamiya plate
  3. Connect the 6V battery holder (+) to the L298N +12V port and (-) to the GND using jumper cables
  4. Connect the arduino GND to the L298N GND
  5. Finally, connect the motors to the L298N two side output ports
  6. Follow my drawing for circuitry for further clarity
  7. 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

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);
 
}

Future Updates

images.jpg
imgres.jpg
Switch.jpg

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!

Donate