I began work on my first robot about two years ago. For no particular reason, I decided to begin with a line following robot and truth be told, my first attempt at building it was a complete failure. Looking back at my efforts, I believe, for a beginner, I was rather too ambitious. The circuit that I had designed had a bunch of unnecessary stuff which I then believed would give my robot an edge over the others. But it never worked and I had to start all over from scratch.

In my second attempt, I managed to get the robot on track. As delighted as I was with my first robot, it was nowhere near where I wanted it to be. I took it to a couple of competitions and not much to my surprise, it failed in both of them. I knew it was time to make some major changes in the design.

In my third attempt, (actually, it wasn’t the third, it was a revision of my second attempt) I updated the firmware and came up with a much more stable and accurate version. It performed well when tested and much to my delight, it finished first in two competitions and second in another. Though I was proud with what I had achieved, I felt that the robot was visually rather unappealing. And you’ll come to know why from its picture given above. It had wires running all over it and I had no other option but to rebuild it. A month or so later, I had the robot all ready and that is the current version of my first robot.

In this instructable I will guide you through the steps that I've followed in building the current version of my robot. It’s one of those robots which belong to the “scratch-built” category. You might find it difficult to find all the parts that I have used. So I insist you to read through the steps that I have followed, and then implement it in your own way with the parts that you've found.

This instructable requires that you are familiar with the following:
• Soldering and related equipments
• Hand tools like screwdrivers, wire cutters and strippers
• Reading schematics and connection diagrams
• C/C++ programming for AVR microcontrollers (optional)

Step 1: Gather the parts

Given below is a list of components that I have used in building this robot.

Electronic Parts
• Atmega32 microcontroller
16x2 alphanumeric LCD
• LM2576 Step-Down Voltage Regulator
L298 Motor Driver Module
Lithium-Ion Rechargeable Battery Pack 11.1V 3000mAh 2C
• 9 x IR Transmitter and Receiver pair (5mm diameter)
• 10K resistor array (9 pin)
• 2N2222 transistor (or any other npn type)
• Resistors and Capacitors
• 2 x Centre Shaft Economy Series DC Motor (100 RPM)
• Switches and Push Buttons

General Parts
• Dot Matrix Prototype PCB
• Plastic Enclosure
• Single-strand Wire
40-pin DIP socket
6 pin FRC right angle male connector
Metal Studs
Plastic Spacers
Nuts and Bolts
Ball Caster Wheel
• 2 x Motor Mounting Clamp
• 2 x Wheel (50mm diameter)
• Cables and Connectors

Tools Required
• Soldering Iron
• Screw Driver
• Wire Cutter and Stripper
• Something to cut and drill plastic

In addition to the above mentioned components, you will also require an AVR programmer and a battery charger.

Now, let’s get started shall we?
<p>I implemented your line following algorithm in Arduino pro mini ........ It works fine ! Thanks :)</p>
<p>bro can you please send me the arduino code.</p>
<p>could you please send me your code ?</p>
<p>Simple code. </p><p>#include &lt;SoftwareSerial.h&gt;</p><p>// Portas LED RGB</p><p>#define PINLEDR 9</p><p>#define PINLEDG 10</p><p>#define PINLEDB 11</p><p>// Portas Sensor de reflet&acirc;ncia</p><p>#define PINSR01 A0</p><p>#define PINSR02 A1</p><p>#define PINSR03 A2</p><p>#define PINSR04 A3</p><p>#define PINSR05 A4</p><p>#define PINSR06 A5</p><p>// Portas driver motor</p><p>#define PININ1 4</p><p>#define PININ2 2</p><p>#define PININ3 7</p><p>#define PININ4 5</p><p>#define PINENA 3</p><p>#define PINENB 6</p><p>// Portas Bluetooth</p><p>#define PINBTX 12</p><p>#define PINBRX 8</p><p>SoftwareSerial serial1(PINBRX, PINBTX);</p><p>void setup() {</p><p> inicie();</p><p> controleLedRGB(255, 0, 0, 1000);</p><p> serial1.begin(9600);</p><p> Serial.begin(9600);</p><p> controleLedRGB(0, 255, 0, 1000);</p><p>}</p><p>void loop() {</p><p>}</p><p>void inicie() {</p><p> // Portas Led RGB</p><p> pinMode(PINLEDR, OUTPUT);</p><p> pinMode(PINLEDG, OUTPUT);</p><p> pinMode(PINLEDB, OUTPUT);</p><p> // Portas Motor</p><p> pinMode(PININ1, OUTPUT);</p><p> pinMode(PININ2, OUTPUT);</p><p> pinMode(PININ3, OUTPUT);</p><p> pinMode(PININ4, OUTPUT);</p><p> pinMode(PINENA, OUTPUT);</p><p> pinMode(PINENB, OUTPUT);</p><p>}</p><p>void controleLedRGB(int r, int g, int b, int tempo) {</p><p> digitalWrite(PINLEDR, LOW);</p><p> digitalWrite(PINLEDG, LOW);</p><p> digitalWrite(PINLEDB, LOW);</p><p> analogWrite(PINLEDR, 255 - r);</p><p> analogWrite(PINLEDG, 255 - g);</p><p> analogWrite(PINLEDB, 255 - b);</p><p> delay(tempo);</p><p>}</p><p>/**</p><p> * Fun&ccedil;&atilde;o para controlar motores</p><p>*/</p><p>void controleMotores(char opcao, int potencia) {</p><p> switch (opcao) {</p><p> case '4': // Direita</p><p> digitalWrite(PININ1, HIGH);</p><p> digitalWrite(PININ2, LOW);</p><p> digitalWrite(PININ3, HIGH);</p><p> digitalWrite(PININ4, LOW);</p><p> analogWrite(PINENA, potencia);</p><p> analogWrite(PINENB, potencia);</p><p> break;</p><p> case '6': // Esquerda</p><p> digitalWrite(PININ1, LOW);</p><p> digitalWrite(PININ2, HIGH);</p><p> digitalWrite(PININ3, LOW);</p><p> digitalWrite(PININ4, HIGH);</p><p> analogWrite(PINENA, potencia);</p><p> analogWrite(PINENB, potencia);</p><p> break;</p><p> case '8': // Frente</p><p> digitalWrite(PININ1, LOW);</p><p> digitalWrite(PININ2, HIGH);</p><p> digitalWrite(PININ3, HIGH);</p><p> digitalWrite(PININ4, LOW);</p><p> analogWrite(PINENA, potencia);</p><p> analogWrite(PINENB, potencia);</p><p> break;</p><p> case '2': // Tr&aacute;s</p><p> digitalWrite(PININ1, HIGH);</p><p> digitalWrite(PININ2, LOW);</p><p> digitalWrite(PININ3, LOW);</p><p> digitalWrite(PININ4, HIGH);</p><p> analogWrite(PINENA, potencia);</p><p> analogWrite(PINENB, potencia);</p><p> break;</p><p> case '0':</p><p> digitalWrite(PININ1, LOW);</p><p> digitalWrite(PININ2, LOW);</p><p> digitalWrite(PININ3, LOW);</p><p> digitalWrite(PININ4, LOW);</p><p> analogWrite(PINENA, 0);</p><p> analogWrite(PINENB, 0);</p><p> break;</p><p> case 'y':</p><p> leituraSensor();</p><p> break;</p><p> }</p><p>}</p><p>/**</p><p> * Fun&ccedil;&atilde;o para ler os dados dos sensores via USB</p><p>*/</p><p>void leituraSensor() {</p><p> serial1.print(&quot;SR01=&quot;);</p><p> serial1.print(analogRead(PINSR01));</p><p> serial1.print(&quot; &quot;);</p><p> serial1.print(&quot;SR02=&quot;);</p><p> serial1.print(analogRead(PINSR02));</p><p> serial1.print(&quot;;&quot;);</p><p> serial1.print(&quot;SR03=&quot;);</p><p> serial1.print(analogRead(PINSR03));</p><p> serial1.print(&quot; &quot;);</p><p> serial1.print(&quot;SR04=&quot;);</p><p> serial1.print(analogRead(PINSR04));</p><p> serial1.print(&quot;;&quot;);</p><p> serial1.print(&quot;SR05=&quot;);</p><p> serial1.print(analogRead(PINSR05));</p><p> serial1.print(&quot; &quot;);</p><p> serial1.print(&quot;SR06=&quot;);</p><p> serial1.print(analogRead(PINSR06));</p><p> serial1.println(&quot;;&quot;);</p><p>}</p><p>/**</p><p> Fun&ccedil;&atilde;o para ler os dados dos sensores</p><p>*/</p><p>void leituraSensorSerial() {</p><p> Serial.print(&quot;SR01=&quot;);</p><p> Serial.print(analogRead(PINSR01));</p><p> Serial.print(&quot; &quot;);</p><p> Serial.print(&quot;SR02=&quot;);</p><p> Serial.print(analogRead(PINSR02));</p><p> Serial.print(&quot;;&quot;);</p><p> Serial.print(&quot;SR03=&quot;);</p><p> Serial.print(analogRead(PINSR03));</p><p> Serial.print(&quot; &quot;);</p><p> Serial.print(&quot;SR04=&quot;);</p><p> Serial.print(analogRead(PINSR04));</p><p> Serial.print(&quot;;&quot;);</p><p> Serial.print(&quot;SR05=&quot;);</p><p> Serial.print(analogRead(PINSR05));</p><p> Serial.print(&quot; &quot;);</p><p> Serial.print(&quot;SR06=&quot;);</p><p> Serial.print(analogRead(PINSR06));</p><p> Serial.println(&quot;;&quot;);</p><p>}</p>
<p>Please send me this code for arduino Rahul..,thanks</p><p>fajar.shellando@gmail.com</p>
<p>Good on you! Can you please post a link to your code. pastebin :-)</p>
<p>could you plz send me the procedure of replicating the same thing on arduino ? thanks in advance :)</p>
<p>could u plz send ur code ?</p>
<p>I am try implemented this code but pushbutton not fungtion. In Lcd showing &quot; Launch calibrate test&quot; stop in here, i pres left button no respon. How Mr. Midun?please help,thanks</p>
<p>Thanks to Mr. Midun..</p>
Bro can we use arduino uno in place of atmega 32
<p>Yup. Possible.</p>
<p>Where, in the rar file, is the main. c please?</p>
<p>do you need the programmer to code this awesome robot because when I opened the program.rar it was just gibberish. Also where is the main. c file please, ?</p>
<p>You will need a programmer. I've used USBasp.</p><p>Did you try extracting the rar file? You will find main.c in it. Let me know if there's some issue.</p>
<p>and to follow black line, is it enough to simply change White to Black?</p>
<p>Yup. That's all you need to do.</p>
<p>hi i'm amila please can you tell me the whole electronics parts which were needed to built up this robot and can you please tell me 390 inductor instead of that what we can used </p>
<p>Kindly go through Step 4. You can use a 470 or 680 or even a 220 inductor. And regarding the electronics part, it will be easy for me if you could be more specific regarding what you need to know.</p>
<p>I get this problem when compiling the code, could you help me deal with this one?</p>
<p>how to fix this error..</p>
<p>I have a question. Say, there is a block on the track. So, the bot cant go any further, it has to turn back. How to deal with that problem?</p>
<p>You could use an ultrasonic distance sensor. You can program the bot to turn around when the distance from the bot to the block is less than a set value.</p>
And 1 question, I have an arduino module. So, any suggestion on the programming part?
okay thanks.
<p>Great instructable. So I have been working on replicating your work, but I'm stuck at the programming part, can you send me your .hex file and does the distance between IR sensor and Emitter is code dependent?(I think everything is good after calibration test)</p>
<p>send it to: jawwad.zahed@gmail.com</p>
<p>Please download the program.rar from Step 17. You will find the .hex file in it.</p>
Thanks midhun_s, but I'm unable to locate the hex file in program.rar
<p>Thank you. The distance between an emitter and its corresponding sensor is not code dependent.</p>
<p>what about <strong><em>invert</em></strong> in a track ??</p>
The answer is in step 35.
can you make this with codevisionavr? help me, im confuse with the program.
<p>I am sorry I ahven't used codevision before.</p>
<p>What are the advantages of the extra sensor in the front as compared to a IR array with sensors in a single row(without the one in the front)?</p><p>In short Does your custom sensor have any advantages over the sensor in the image below?</p>
<p>In the algorithm in step 24 you can see how the front sensor helps in determining in advance whether the robot is over a turn or over an intersection. You could do this even without the front sensor but in some cases, where the track width is more, it prevents the robot from falsely identifying a straight line for a turn.</p>
<p>I would be grateful if you could provide me the PDF file of this book to my email address. My email address is mohib.cse.bd@gmail.com. I would like to work with robotics. Thanks.</p>
<p>consider the sensor in the image has 8 pairs of IR leds but none in front.</p>
<p>There is no separate circuit for calibration. It's all done in the program. If it's the sensor array circuit that you're searching for, you can find that in <a href="https://www.instructables.com/id/Robot-Line-Follower/#step5" rel="nofollow">step 5</a>.</p>
<p>can u plzzz provide with the calibration circuit......i mean how to make.???? connections and all...............plzzzz </p>
<p>what is the minimum rating for battery current wise voltage wise and charge wise</p>
<p>i want to download the pdf of the line follower ropot</p><p>can i get help?</p>
<p>can someone pls explain to me what is the device in step 17. must it be made or can be purchased? </p>
<p>Just look for &quot;AVR Programmers&quot; and follow vendor instructions about how to program your ATMEGA32. Here's one suggestion: </p><p>https://www.sparkfun.com/products/9825</p>
<p>Should there be a Piece paper between emitter and receiver</p>
You could use heat shrink tubes instead. I've tried and it worked just fine. 5mm heat shrink tube should fit snugly on the emitter.
<p>There are four dip switches in the usbasp programmer what is their function</p>
Switch 1 turns the programmer circuit on/off.<br>Switch 2, if turned on, provides 5V supply from USB port to the target.<br>Switch 3 sets slow programming mode on/off. You will have to turn this on when you are flashing program or writing bootloader into an Atmega for the first time.<br>Switch 4 is rarely used and it allows to update the firmware on the programmer through the same 6 pin ISP used for programming.
<p>what is the use of 1st and 8th sensor? can't we make it with 7 sensors and one front sensor?it would make a byte as well</p>
Certainly. Removing one sensor might not seriously affect the performance. But that would mean you will have to consider the front sensor as one among the seven bits. I think this would make the program part a little complex as you cannot directly associate the bit positions with the physical layout of the sensors. After all, more sensors you choose, more are your possibilities of fine tuning your robot.

About This Instructable




More by midhun_s:Robot - Line Follower 
Add instructable to: