/*Program : LCD KARAKTER KEYPAD SHIELD 16X2
Chip : Arduino Uno
Date : 25/06/2015
Created : Mark Bramwell
Modified : Lab-elektronika Team
email : [email protected]
Sumber : labelektronika.blogspot.com
********************************************************/
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int tombollcd = 0;
int bacatombol = 0;
#define tombolright 0
#define tombolup 1
#define tomboldown 2
#define tombolleft 3
#define tombolselect 4
#define tombolnone 5
int read_LCD_buttons()
{
bacatombol = analogRead(0);
if (bacatombol > 1000) return tombolnone;
if (bacatombol < 50) return tombolright;
if (bacatombol < 250) return tombolup;
if (bacatombol < 450) return tomboldown;
if (bacatombol < 650) return tombolleft;
if (bacatombol < 850) return tombolselect;
return tombolnone;
}
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("TEKAN TOMBOL");
}
void loop()
{
lcd.setCursor(0,1);
tombollcd = read_LCD_buttons();
switch (tombollcd)
{
case tombolright:
{
lcd.print("RIGHT ");
break;
}
case tombolleft:
{
lcd.print("LEFT ");
break;
}
case tombolup:
{
lcd.print("UP ");
break;
}
case tomboldown:
{
lcd.print("DOWN ");
break;
}
case tombolselect:
{
lcd.print("SELECT");
break;
}
case tombolnone:
{
lcd.print("NONE ");
break;
}
}
}