I changed the sample routine of my keypad shield for getting the current button. Instead of separate if clauses I now use if else, ... However, now it throws a not defined error for all constants declared by #define. If I change this definitions to constants, same happens. What's the trick?
int lcd_key = 0;
int adc_key_in = 0;
int lastButton = 0;
int curButton = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
if (adc_key_in < 50)
curButton = btnRIGHT;
else if (adc_key_in < 195)
curButton = btnUP;
else if (adc_key_in < 380)
curButton = btnDOWN;
else if (adc_key_in < 555)
curButton = btnLEFT;
else if (adc_key_in < 790)
curButton = btnSELECT;
else
curButton = btnNone;
if (curButton == lastButton)
return btnNone;
else return curButton; // when all others fail, return this...
}