IR Based Line Following Robot From Scratch [No Microcontroller]

2,152

15

9

Introduction: IR Based Line Following Robot From Scratch [No Microcontroller]

About: Electrical Engineer and a programming hobbyist! I love to build exciting stuff!

In this instructable we'll use the concept, reflection of infrared radiation to built a circuit which can detect the difference between black and white coloured surface. That might not sound interesting but later we can use that circuit to build a robot which will follow a black line, and the best part is, the whole build is purely based on electronics and no programming or coding is required! If you are getting started with electronics or getting a concept of science into a project this would be a great place to start. So, grab the components mentioned below and get started with the instructable.

Supplies

These are the list of products which can help you do this project with ease

(Affiliate Link)

Step 1: Infrared Radiation

Light is a complicated topic in physics because of it's dual nature where it act as both particle and wave at the same time. To understand how this project works will just stick on to our pal Maxwell and consider light as electromagnetic waves! These waves consists of several wavelength starting from from the shortest wavelength Gamma waves to the longest wavelength Radio Waves . The most common electromagnetic waves that everybody experience in day to day life is from 380nm to 740nm A.K.A “the visible region” or "the visible light".

Similarly, Infrared Radiation is part of the electromagnetic spectrum with the wavelength of 700nm to 1mm. infrared radiation has slightly longer wavelength than the visible light therefore this radiation is invisible to human eye but can be caught on most of the camera.

[Note : Infrared radiation also obeys all the laws of reflection and the laws of refraction just like the visible light]

Step 2: Source of IR Radiation

Sun is major source of electromagnetic radiation but most physical body emit some sort of radiation based on there property like nuclear radiation by nuclear substances (Gamma waves), heat produced by human body (infrared radiation), etc. Infrared radiation is produced by all the physical object which have temperature more than absolute zero or -273k(approx.). But the magnitude of infrared radiation produced is very small so, the IR detector which we use in this project cannot capture them. Therefore we will have to use an IR emitting LED which emit infrared radiation with greater intensity. There are two types IR LED narrow band and a wide band. In this instructable we'll use a narrow band IR emitting LED and in later steps we'll see the reason, why we chose this.

Step 3: Formation of Colour

Between 380nm to 740nm we have visible light, this visible light is further divided into different colours based on the wavelength [eg : Green - 590nm to 635nm]. When all these colours is removed form the spectrum it becomes dark/black because our eyes don't receive any input and combining all the colours in the spectrum we perceive the colour white. By now the concept of colour makes sense in electromagnetic waves but the interesting question to ask is... what makes the physical object like plant Green? and apple Red?

Every object absorb and transmit light in some or the other way. When the light strikes the surface of the object, different wavelength of light get absorbed depending on the molecular composition of the physical object. So whatever colour we see is just the reflected wavelength of the light which is not absorbed by the object. In the same context we see the colour white because of reflection of the all the wavelength of light that wasn't absorbed by the body and finally black is due to absorption of all the wavelength of the light (Even though we don't see Infrared radiation the concept of absorption and reflection remains exactly the same).

[Note : Whatever we talked so far will only be 100% true in a perfect world! In reality some wavelength is always absorbed and reflected]

Step 4: Designing the Circuit

We need a circuit which can give a high signal when it's on black line and low signal when it's on white surface. For this we need to read the intensity of IR reflection on the surface caused by IR LED. To read the intensity of light we need to use a IR receiver.

Since we are going to use the reflection of IR light, the IR captured by the receiver will be very small and wouldn’t be useful to use in our circuit because of it's analog nature so, we'll build a amplifier and voltage comparator using IC 358 (OPAMP) and finally to show the output we'll use a RED LED.

Step 5: Working With IR Receiver

The IR receiver looks similar to a LED which is tinted black. This has to be connected in opposite direction to the polarity or in technical term the receiver diode has to be reverse biased. In reverse biased condition receiver act as a water valve, depending on the intensity of IR light falls on the receiver the current flow through the receiver proportionally, just like the valve let the water flow as you open the valve (If no IR light is captured by the IR receiver there will be no current flowing).

We'll build a voltage divider using the receiver diode and a 10k resistor. This will help us get the voltage value and this voltage value is affected by the amount of infrared light that falls on it so, we can give this as an input to the comparator to decided the output. (If the IR reflection is more then the voltage across the receiver diode reduce (white surface) and when the IR reflection is less then the voltage across the receiver diode increases (black surface))

Step 6: OP-AMP As Comparator

Op-amp comparator is a comparator circuit which takes 2 voltage level as input and outputs HIGH(VCC) or LOW(GND). If the input to inverting terminal of the op-amp is greater than non-inverting terminal, then the output is LOW and when the non-inverting terminal input is greater than the inverting terminal then the output is HIGH.

We can built the comparator by placing 2 potentiometer at the inverting, non inverting terminal input and a LED at the output of the op-amp. Now when you power the circuit and adjust the potentiometer the input the op-amp will be varied when input to inverting terminal of the op-amp is greater than non-inverting terminal, then the output is LOW and the LED doesn't glow. When the non-inverting terminal input is greater than the inverting terminal then the output is HIGH and the LED glows.

[Link for more detailed/technical guide on op-amp as comparator]

Step 7: Building the Sensor

we’ll just replace one potentiometer with the receiver diode positive terminal to inverting terminal of the op-amp and connect a led with 220 ohm’s resistor to see output. So, the working is very simple, there will be decrease in voltage across receiver when IR light strike the receiver and this decrease will be compared by op-amp with the voltage set by the potentiometer and triggers the output.

As we know the circuit works! it’s time to build the circuit in a perf board. I just placed the components in the board as exactly as the circuit diagram and soldered them together.

[Hint : Make sure that the IR transmitter and receiver are placed as closely as possible for better sensing]

Voila! we have successfully completed the IR proximity sensor. if you don't want to build this, you can also buy exactly the same circuit from an online store.

Step 8: Working of the Bot

Before moving with the bot replicate the sensor on both side of the PCB.

You might ask why the stroke with of the line is so large where it's technically just a rectangle and not a line anymore, that because the line should be able to completely absorb the IR light emitted by the IR transmitter LED so we can detect we are on the black surface.

When the line is between 2 sensors the bot runs both the motor and makes the bot move forward, but when any one of the sensor detects the black surface, the motor adjacent to the sensor is stopped and the other one continues to move forward. This motion gives turn to the bot and by doing this back and forth on both the motors the bot aligns itself on the line.

Step 9: How Does L293D Works?

We can't just connect the motors directly to sensors, just like we did with the output LED because the motors requires large current compared to an LED. So if we connect the motor to the sensor, it will destroy the circuit.

Therefore we need a motor driver, In this case I'm using a IC called L293D[datasheet].

With this IC we can control 2 motors (clockwise and anticlockwise direction) using just 4 pins.

  • Pin 2 and Pin 7 to control one motor which is connected to pin 3 and pin 6.
  • Pin 15 and Pin 10 to control the other motor which is connected to pin 11 and pin 14

When the input is '1'(HIGH) to pin 2 and '0'(LOW) to pin 7 the motor turns clockwise and when the input is '0'(LOW) to pin 2 and '1'(HIGH) to pin7 the motor turns in anticlockwise direction. But if the input to both the pins are same either 1(HIGH) 1(HIGH) or 0(LOW) 0(LOW) the motor stops spinning. This same logic is applicable for the other motor connected on the pin 14 and pin 11.

Step 10: Building the Line Following Robot Circuit

We can get the final circuit by just combining both circuit from step 7 and step 9. Where one sensor output is attached to one pin of the L293D input (for 1st motor input) and the other sensor output is also connected to L293D input (for 2nd motor input).

To finalize the circuit I used a perfboard to solder all the components of the motor driver and I used the header pins to create a connection between the sensor board and the motor driver board. Also I have drilled few holes on the PCB where I can use them for assembly.

Step 11: Final Assembly

You can build a custom chassis to hold the motors and the circuit by 3d printing or by laser cutter, but to keep things simple I have used the PCB as part of the chassis for the bot and to have a better support I sandwich the motor between the PCB that we build and a copper clad of same dimension. To keep them attached I used some fasteners(bolts and nuts) and some hot glue. Once the body was done, I used a caster wheel as the support wheel for the bot. That's it, this concludes the assembly for the bot.

Step 12: Power Supply

You can just use a 9v battery for the power source as both IC 358 and IC L293D tolerant to that voltage.

But the issue with this method is the 9v battery exhaust very soon. So, I used a single 18650 Lithium Ion battery along with a boost convertor (convert 3.7v to 5v) to run this bot. Along with this you can use tp4056 to charge the battery or instead you can use the Lipo charger mentioned in the supplies to charge the battery externally.

Step 13: Final Thoughts!

This project does comes with few limitation of there own

  • They don't work well with 90 degree turns
  • The bot just stops if it find a 'T' junction because it triggers both sensor which stops both the motor
  • The bot hard stop the motors to align itself on the line, which create a jerk motion rather a smooth transition

Advantages of this bot

  • No programming is required
  • Cost of the overall build is relatively less
  • Very basic knowledge of electronics is required

Let me know what you think about this Instructable, if you would like to read more check out my profile or you can checkout my YouTube channel.

Explore Science Challenge

Participated in the
Explore Science Challenge

Be the First to Share

    Recommendations

    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Halloween Contest

      Halloween Contest
    • Organization Contest

      Organization Contest

    9 Comments

    0
    Palingenesis
    Palingenesis

    4 months ago

    Very good instruction, lots of detail, well done.
    I like the way you have explained how it all works.

    0
    Neutrino-1
    Neutrino-1

    Reply 4 months ago

    Glad you like it!

    0
    Ranuga
    Ranuga

    4 months ago

    This project is only for fun. am I correct because a line follower can be easily made up with an Arduino microcontroller and a motor controller. There are thousands of line following projects. Anyway thanks for sharing:)

    0
    memjr73
    memjr73

    Reply 4 months ago

    There is actually no need to use a microcontroller to make a line following robot at all, as shown by the author of this instructable.

    Analog line followers are very old. Everyone started using microcontrollers to make them when microcontrollers became really cheap.

    The simplest analog line follower can be made with 2 transistors, 2 resistors, and 2 LDRs to control 2 motors. LEDs aren't even needed (infrared or otherwise, although a built-in light source will make the bot usable in more diverse surfaces and line colors\conditions). And, no programming needed!

    Meanwhile, a microcontroller has thousands, if not millions of transistors and you still need more power transistors or motor controller chips (with even more transistors in them) to control the motors.

    Taking that into account, one quickly realizes how complicated and massively over engineered a microcontroller line follower bot really is.

    0
    Ranuga
    Ranuga

    Reply 4 months ago

    Yes actually, But I never mentioned its a trash, only I sed with the time pass it's good to use microcontrollers as now the world is joining with microcontrollers.

    0
    memjr73
    memjr73

    Reply 4 months ago

    For a given set of requirements, the simplest solution is always the best. If the requirements are "a bit that follows a black line on a white surface", the 2 transistor solution is the best as it is the simplest.

    0
    Neutrino-1
    Neutrino-1

    Reply 4 months ago

    Yes! The line follower bot I made have lot of flaws and cannot work as good as the one made with microcontroller. This instructable was just to educate the physics behind the sensor/bot and also how to convert a physics/science concept in terms of electronics.
    Glad you like it!

    0
    memjr73
    memjr73

    4 months ago

    How refreshing to see someone post a line follower without a MCU in it. Those a so overly complicated and still require transistors to control the motors when a simple analog line follower requires only a few components and no MCU at all.

    Well done!

    0
    Neutrino-1
    Neutrino-1

    Reply 4 months ago

    Glad you like it!