Skip to content

This library is for the Cytron Line Sensing Array: LSA08

Notifications You must be signed in to change notification settings

shashank3199/LSA08

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version Tag

Introduction

This library is for the Cytron Line Sensing Array: LSA08 (reference here).

Index

User guide

Downloading the library

It is suggested that you download the entire repository and then select this folder, so that you can enjoy the benifits of VCS like git. It makes it simpler to update the contents whenever patch fixes are done. You can simply open a terminal (or gitbash on windows), go to the folder where you want to save this repository and type the following command.

git clone https://github.com/shashank3199/LSA08.git

Not recommended: You can download only this folder by clicking here

Using the library with Arduino

Move this folder into the arduino libraries folder on your PC. If you don't know where the libraries folder of your arduino is, you can click here.
Also, this Library makes use of the DebuggerSerial Library. For More Information on this, click here.

In order to use this library, you must do the following:

  • Include the header file LSA08.h (the LSA08 library folder must be in your arduino libraries folder).
  • Create an object of class LSA08. You can pass the constructor parameters to initialize here itself, or leave it as a simple object declaration.
  • Initialize the Serial on which the LSA is attached using the AttachSerial function. You may optionally initialize and attach a debugger serial as well (using debugger.Initialize function on the object). You can access the debugger using the debugger variable of the class.

Library Explanation

The Library uses the LSA Module with the following Pin Out -

Image

About LSA08

Setting Menu of LSA08:

Menu Description
LCD Contrast (LCD CON) Setting the contrast of LCD.
Calibration (CALB) Calibrate LSA08 to the colour brightness of the line and background.
Line Mode (LINEMODE) Setting LSA08 to be Dark On (for dark line and bright background) or Light On (for bright line and dark background).
Threshold (THRES) Set according to the surface condition of the line. It is the number of Lines in a bar as shown on the LCD. The threshold value can be set from 0 to 7.
Junction Width (J WIDTH) The number of bar chart on LCD for a junction crossing.
UART addressing (UART ADD) Application Not Applicable here.
UART Baudrate (BAUDRATE) Setting the baudrate of the UART Communication.
UART Mode (UARTMODE) To be Set as 2
LCD Backlight (LCD B/L) Setting the LCD backlight brightness
Exit (EXIT) Exit Menu

Note: Press and hold Mode button on any main menu will exit the menu.

Baudrates for the LSA08:

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

Examples

SerialRead

This example show you to Read values from the LSA using the LSA08 library on Serial2 without the use of any Buffer.
File: ./examples/SerialRead/SerialRead.ino

We simply follow the following steps:

  1. Include library
  2. Create object
  3. Initialize Serials. LSA08 on Serial2 and debugger on Serial. Keep in mind to match the baud rates.
  4. Initialize debugger. Name it LSA.
  5. Then start a loop
    1. Read LSA Values using ReadLSA Function.
    2. The Values will be printed by the Debugger Object.
  6. Re-run the loop

SerialRead_Buffer

This example show you to Read values from the LSA using the LSA08 library on Serial2 using a Buffer or by using the Enable Pin (if not Grounded Electronically).
File: ./examples/SerialRead_Buffer/SerialRead_Buffer.ino

We simply follow the following steps:

  1. Include library
  2. Create object
  3. Initialize Serials. LSA08 on Serial2 and debugger on Serial. Keep in mind to match the baud rates. Also, set the Pin Value for the Buffer Control Pin (or Enable Pin) and Active State of the Buffer Control (LOW incase of the Default Enable Pin).
  4. Initialize debugger. Name it LSA.
  5. Then start a loop
    1. Read LSA Values using ReadLSA Function.
    2. The Values will be printed by the Debugger Object.
  6. Re-run the loop

AnalogRead

This example show you to Read values from the LSA using the LSA08 library using the Analog Pin.
File: ./examples/AnalogRead/AnalogRead.ino

We simply follow the following steps:

  1. Include library
  2. Create object
  3. Initialize Serials. LSA08 on Pin No: 8 and debugger on Serial.
  4. Initialize debugger. Name it LSA.
  5. Then start a loop
    1. Read LSA Values using ReadLSA Function.
    2. The Values will be printed by the Debugger Object.
  6. Re-run the loop

Developers guide

Library Details

Files in the Library

The files in the library are :

LSA08.h

This is the Header file and contains the Class Blueprint (Prototype).

LSA08.cpp

This file contains the Definiton for the Class Member Functions Prototyped in the Header File.

README.md

The Description file containing details about the library. The file that you looking at right now.

Class Contents

Let's explore the contents of the class, but first, we also have literals defined for general purpose use (using #define). They are:

Name Value Purpose
MODE_SERIAL 0 Value passed to select the Serial Mode for receiving Values.
MODE_ANALOG 1 Value passed to select the Analog Mode for receiving Values.
Name Value Purpose
BUFFER_OFF 0 Indicates that the Serial is not connected to any Buffer.
BUFFER_ON 1 Indicates that the Serial is connected to a Buffer.

Let's explore the class now

Private members

Variables
  • HardwareSerial *LSASerial: This is the serial on which the LSA operates.
  • int currentValue: The LSA Value at Present.
  • int previousValue: The Last Non - 255 Value of the LSA.
  • int analogPin: Pin Number to which the Analog Pin of the LSA is connected.
  • int flagValue: Reference Value of the LSA indicating the following -
Flag Value LSA Value ( Range )
0 0
1 1 - 34
2 35
3 36 - 69
4 70
5 255
  • bool bufferStatus: Indicator whether the LSA is connected to a buffer or not.
  • int bufferPin: Pin Number of the Buffer Control Pin.
  • bool bufferPinStatus: Active Status for the Buffer Control Pin.

Member functions

  • voidClearLSA ( ) : Clear the Junk Values from the LSA.
  • voidSetFlag ( ) : Set the Flag Value for the LSA.

Public members

Members

Constructors

  • LSA08 ( ) : Empty constructor for the class.
  • LSA08 ( HardwareSerial *LSASerial ) : To attach a pre-initialized serial to the LSA. This function calls the AttachSerial member function along with the previously mentioned Constructor using Constructor Delegation.
  • LSA08 ( HardwareSerial *LSASerial , int bufferPin , bool bufferPinStatus ) : To attach a pre-initialized serial to the LSA on a Buffer. This function calls the SetBuffer member function along with the previously mentioned Constructor using Constructor Delegation.
  • LSA08 ( int analogPin ) : To Set the Pin Number to which the Analog Pin of the LSA is connected. This function calls the AttachAnalogPin member function.

Member functions

  • bool operator == ( int flagValue ) : Checks for Equality of a Flag Value directly with the LSA Variable.

  • bool operator != ( int flagValue ) : Checks for Inequality of a Flag Value directly with the LSA Variable.

  • operator int ( ) : Implicit Type Conversion from Object Type: LSA08 to int Type for Easy Assignment and Comparision.

  • void SetBuffer ( int bufferPin , int bufferPinStatus ) : Sets the Buffer Control Pin and Value for the LSA.

  • void AttachSerial ( HardwareSerial *LSASerial ) : Attach the Serial to the LSA.

  • void AttachSerial ( HardwareSerial *LSASerial , int bufferPin , bool bufferPinStatus ) : Attach the Serial to the LSA. and Sets the Buffer Control Pin and Value.

  • void AttachAnalogPin ( int analogPin ) : Set the Analog Pin for Receiving Value in Analog Mode.

  • int ReadLSA ( ) : To Receive and Return the Current LSA Value.

  • int GetPreviousValue ( ) : To Return the Last Non - 255 Value of the LSA.

References

Developers Tag

About

This library is for the Cytron Line Sensing Array: LSA08

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages