
VMA203
V. 02 – 16/01/2019
5
©Velleman nv
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/
return btnNONE; // when all others fail, return this...
}
void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Velleman VMA203"); // print a simple message
}
void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
// if You need the word "LEFT " shown on the display than use lcd.print("LEFT ") instead of
lcd.print(adc_key_in) and lcd.print(" v");
// the following 2 lines will print the actual threshold voltage present at analog input 0 ; As these buttons
are part of a voltage divider, pressing each button creates a different threshold voltage
lcd.print(adc_key_in); // shows the actual threshold voltage at analog input 0
lcd.print(" v"); // ends with v(olt)
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}