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. 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.

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 crossed 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 allow 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.

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.

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

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.