News: Emoro Community Building Challenge Read more


  • gallery

Line following robot


I purchased an EMoRo robot kit. The kit itself has all the necessary components for a line following robot, which I decided to make as a project. In the next few easy steps you'll see how the project was accomplished and you'll be able to make one by yourself.

  1. Installation
  • First of all you will need to download Arduino IDE by visiting and install it so you can program EmoRo2560 controller. Furthermore, in Arduino IDE to install an EMoRo library go to Sketch>Include Library>Manage Libraries>EMoRo>Install. After installing Arduino IDE connect EMoRo controller with your computer and the computer should recognize it automatically. Following the instructions, I built a robot equipped with two servo motors connected to two rear wheels, two IR sensors and an EMoRo controller.
  1. Concept
  • The concept of line following robot is related to light and the colour of the surface which it drives on. When light falls on a black surface it is absorbed, and by falling on a white surface it is reflected. IR radar consists of an IR transmitter and IR receiver. The IR transmitter generates IR light which is absorbed by a black surface, while it reflects of a white surface and the IR receiver catches the light. In this case when IR radar detects a white surface the controller gets value 1 as input and by sensing a black surface it gets value 0 as input.
  • A pair of servo motors is used to control the wheels. Default neutral position of servo motors is 1500 us, the clockwise rotation when PWM width is decreasing from 1500 to 500 us, and the counter clockwise rotation is obtained when the PWM width is increasing from 1500 to 2500 us. The properties listed will be used when programming the movement of a line following robot.
  1. Programming

Line follower code

  • The programming part I started by using the examples of Arduino based projects for the use of IR sensors and servo motors and examples given in the EMoRo library. The Arduino program I started by defining the values for each motor. For the left wheel to go forward I gave it the value 500 so it can rotate clockwise, for it to go back I gave it the value 2500 so it can rotate counter clockwise and for the right wheel 2500 so it could rotate clockwise going forward and 500 so it could rotate counter clockwise and go back. For the robot to stop, I defined variables for the left and the right wheel giving them values 1500 for the neutral position of the servo motors.
  • In the setup I initialized all available inputs and outputs on EMoRo 2560 „InitEmoro();“ and after that initiated servo motors on SERVO_1 port and SERVO_2 port „EmoroServo.attach(SERVO_0);“ , also initialized serial communication with „Serial.begin(9600);“ and initiated input mode with pullup – IR sensor on IO_1 and IO_2 port „pinMode(IO_0, INPUT_PULLUP);“.
  • I used the ‘if’ loop to test if the IR sensors were detecting a white surface and if they are the robot drives forward. In the next if loop I tested if the pair of IR sensors are detecting a black surface in which case the robot should stop. However if only one sensor detects a black surface the robot should get back on the track and go left if the left sensor detects a black surface, and go right if the right sensor detects a black surface.
  1. After finishing the program, I verified the code and connected the EMoRo controller to the computer and uploaded the program. While connected to the computer I tested if the sensors work properly, if they detect a white surface there should be a red light next to the IO_0 and IO_1 port and if they detect a black surface the lights are turned off. I disconnected the controller from the computer, built a track with a black duct tape on a white surface and set the robot on a track, by turning the power switch on the robot drove on the track.

With these easy steps everyone is able to build and program a line following robot and have fun afterwards.

Link to video: