Line-Following Robot Using LSA08 in Serial Mode with Digital Output

Introduction Good day, The Advanced Auto-Calibrating Line Sensor (LSA08) is capable to operate in three 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 serial mode with Arduino Uno board.


Good day,

The Advanced Auto-Calibrating Line Sensor (LSA08) is capable of operating in three 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 serial mode with an Arduino Uno board. However serial mode of LSA08 support 3 different output modes: 8-bit digital data representing each sensor state (1 or 0), 1 byte data that representing the line position (0 – 70), 8 continuous data bytes that representing analog reading of each sensor. For this tutorial I will introduce the basic of LSA08 in serial mode, with 8-bit digital data output.



Before we could start, let’s take a look at what we need.



and some materials for robot base.


Arduino IDE – an open source Integrated Development Environment used to program Arduino board. You can download it here.



Alright, now we have all we need, let’s start by making a robot base. 1…2…3……

Here we go, a robot base~

In case you wondering the steps of robot making, you can view it here. A small precaution here is to make sure that the base is larger than 20cm x 20cm, so you can mount everything we need on it.

So the next thing is to mount everything on it, like this…

Here is the connection that you will need, we will discuss about the connection of LSA08 after this.

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 the one at left.

(Click the image for larger view)



Still with me? I assume that you are here. So the next thing is to talk about LSA08 as I promised.

Figures at the left shows the Advanced Auto-Calibrating Line Sensor (LSA08) line sensor that I always mentioned about. What makes it different with the normal Auto-Calibrating Line Sensor (LSS05) is that it has the word “advanced” in its name (of course).

LSA08 has 8 sensor array rather than 5 in LSS05, besides it also allows the user to manually select the line sensing option through its setting menu.

Here is the list of available setting for LSA08. More explanation about the setting menu will be discussed later.

(Click the image for larger view)

We have the pin layout for PORTA which is used for serial and analog mode.

The connection is as shown in the table below:

 LSA08 pin Arduino Uno board
1 RX (pin 0)
2 TX (pin 1)
3 digital pin 2
4 not used
5 digital pin 4
6 not used
7 not used
8 not used
9 Vin
10 GND

*NOTE: make sure this is PORTA, and input voltage ranging from 7.5V – 20V

All done? Good, after that we can really talk about the setting menu. First, power up your board, and you will see something like this.

The 8 bars at the top display the sensor value for each sensor. The number at the bottom left of LCD display the current line position, while the ‘J’ at the bottom right will show up whenever it crosses a junction.

Now, pressing the MODE button on board will bring you to the setting menu. In the setting menu, press MODE button to loop over the menu, and pressing SEL button will enter to option setting.

Pressing SEL button in option setting allows you to choose the desired option for that setting, and press MODE when the LCD display the desired option will save the setting and return to setting menu.

Let’s see what we can do with the setting menu.

LCD Contrast (LCD CON)

Use this setting to adjust the contrast of LCD display.

Calibration (CALB)

Pressing SEL will put your LSA08 into calibration mode, and you have to start moving sensors across the black line like there is no tomorrow =P.

Line Mode (LINEMODE)

Allows user to choose either Light-On mode or Dark-On mode. Sensor will output 1 when detect white surface, 0 when detect dark surface during Light-On mode, and vice versa.

Threshold (THRES)

Allows user to set the number of bar chart on LCD required for LSA08 to assumes it as a valid line detected.

Junction Width (J WIDTH)

Allows user to set the number of sensors detect line in order for LSA08 to assumes as a junction cross.


Allows user to identify which LSA08 the user refers to when working with multiple LSA08. Address for each LSA08 in  the same system must be unique to avoid ambiguous cases.


Allows user to select the baudrate used in UART serial communication.

The baudrate can be set as list below:

No. Baudrate
0 9600
1 19200
2 38400
3 57600
4 115200
5 230400


Allows user to choose the output send to host (stated above) when UART output enable pulled LOW.

No. Mode
0 no data output
1 8-bits digital output
2 1 byte analog output
3 8 continuous bytes of analog output package

LCD Backlight (LCD B/L)

Allows user to choose a suitable backlight for LCD. Value 0 means the backlight is OFF.

Exit (EXIT)

Press SEL button to exit the menu, or press and hold MODE in setting menu will also bring you back to line display screen.

For complete information on LSA08 setting, please refer to its user manual from Cytron’s product page.

LSA08 also allows user to set the configuration through UART serial communication with following specification:

And here is the command reference table:

(Click the image for larger view)

The command send to LSA08 must be in 4 continuous bytes within 20ms in the arrangement of:

|Address | Command | Data | Checksum|

where Checksum is the sum of Address, Command, and Data, if the result is more than 1 byte, only lower byte is taken. So we can simply say that:

Checksum = LowByte(Address + Command + Data)

LSA08 will respond with “OK” for every successful command received. However, for command such as retrieving line position, and junction count will be replied with the data requested instead.


You can download the source code at attachment below.

Upload the sketch commandTest.ino into your Arduino board, and it will help you to configure the LSA08 into a setting that is suitable for our line following task to work.

Video below shows how this program works.

After that, upload LSA08Serial.ino 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.

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




Line-Following Robot Using LSA08 in Digital Mode


Source Code Here


2 thoughts on “Line-Following Robot Using LSA08 in Serial Mode with Digital Output”

  1. hi… i am also design above type of line following robot for robotics competition… in my case first i want to follow bright line in dark background(first area). after that robot complete the first area it entering to the second area. in this second area robot should follow the dark line in bright background. so i want to know whether LSA08 sensor can be used to my application. because i am confuse when it calibrate to detect bright line in dark background how should i change the calibrating setting to detect dark line in bright background.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
TinyML on Arduino using Edge Impulse
Tutorials of Cytron Technologies Scroll to Top