Bukit Mertajam, Penang

Line-Following Robot Using LSA08 in Analog Mode


Good day,

The Advanced Auto-Calibrating Line Sensor (LSA08) is capable of operating in 3 different modes: digital, analog, and serial. In this tutorial, I am going to show you how to make a line following robot using LSA08 in analog mode with an Arduino Uno board.

I have written a tutorial about LSA08 in digital mode, please refer to it here as the materials and procedures are almost the same. Now, let us discuss the different between digital and analog mode.

Additional Information

Let’s take a look on how the LSA08 analog mode works, and how are we going to interpret the data.

Analog output mode of LSA08 allow users to retrieve line position in the range of 0 – 70 representing the right most sensor to the left most sensor, with 255 as no line detected. This value is converted into voltage signal ranging from 0V to 4.5V indicating 0 – 70, and 5V for 255 no line detected, where the user can get the reading through Analog-Digital Converter (ADC).

The ADC modules of Arduino Uno support 10-bit conversion, so each step size of the result represent 5V/2^10= 4.88mV, meaning that an increase of 4.88mV in the reading will increase the result of ADC conversion by 1.

So, to convert the voltage signal back into what we human can understand, we need to use the formula ((ADC result)/921)*70 in order to get the actual position of the line. Why divide by 921? Because 921 is the digital representation for 4.5V in 10-bit ADC.

To make the program more beginner friendly, I have separated the line position into 4 categories as below:

  • 0 – 18, the line at left hand side, robot needs to move left
  • 19 – 52, the line at center, robot move forward
  • 53 – 70, the line at right hand side, robot needs to move right
  • any value other than 0 – 70, robot stop moving


I assume that you have gone through the tutorial in digital mode here, or at least make yourself a robot base.

Now, connecting Arduino board to MDD10A, notice that I did not connect 5V pin on MDD10A because there is no such pin on my real board, you have to connect it to 5V pin on your Arduino board if such pin exist.

switch is highly recommended to avoid your robot running away once you connect the battery =P.

In the end, your connection should looks like shown in the figures.

(Click the image for larger view)

The connection for analog mode is much more simple than in digital mode, as you only require 4 wires to connect to the LSA08.

Referring to user manual from Cytron product page, connect LSA08 to Arduino board as shown in the table below:

LSA08 Arduino
Vin Vin
AN analog pin 0 (A0)
Junction pulse digital pin 4

*NOTE: please make sure that you connect to the PORTA on LSA08

(Click the image for larger view)

You can download the source code at the attachment below.

The LSA08 calibration for analog mode is the same as in digital mode, so please refer here to study about sensor calibration.

Alright, the last thing is to upload the sketch to Arduino board, and run the program. If your robot moving in a wrong way, try changing the polarities of your motor, or changing the state values where I mentioned in the source code.

There is one last thing that I want to repeat again, please make sure that you are connecting to PORTA of LSA08. Enjoy the video, but it is almost the same as video for digital mode =p.

Finally, if you have any question, feel free to ask in our technical forum as we seldom check the tutorial’s comment section.


Related Posts

Comments (2)

Sir, a lot of error in reading the analog value is coming in uploading your code. Can you give me the correct code with no error

Leave a comment