Tutorial 5: Sensors and LCD Output
For this tutorial, you will learn how to read values from some basic
sensors using the EyeBot. You will also learn how to display the data
as output on the LCD. For reference, all the programming commands for
the EyeBot can be found here
(Click on Controller -> Libraries).
Key Input
The input from the four keys on the front of the keypad can be obtained
with the functions KEYGet()
and KEYRead(). The main
body of your programs will probably be contained in a while loop with
a keypress as a condition statement. For example
void main()
{
int key;
//Initialize other variables
key = KEYRead();
while(key != KEY4)
{
// do something
key = KEYRead();
}
}
Analog Input
To obtain analog input, use the command OSGetAD.
When obtaining data from more than one channel of the A/D converter
in succession, you may find that the values are identical. If this happens,
insert an OSWait command
between reading times, or perform other computations between samples.
LCD Output
The most useful function for debugging is probably the LCDPrintf
statement. The parameters passed to the function are exactly the same
as the C printf function.
You will also find the LCDSetPixel,
LCDGetPixel, and LCDLine
functions to be useful for the drawing items on the screen.