implement PIR timeout
[Arduino] / LCD_Keypad_Shield / LCD_Keypad_Shield.ino
index 380e710..abf000d 100644 (file)
@@ -12,9 +12,10 @@ char msgs[5][15] = {"Right Key OK ",
                     "Down Key OK  ", 
                     "Left Key OK  ", 
                     "Select Key OK" };
-int  adc_key_val[5] ={30, 150, 360, 535, 760 };
+int  adc_key_val[5] ={1, 520, 690, 770, 820 }; // max  
 int NUM_KEYS = 5;
 int adc_key_in;
+int old_adc = 0;
 int key=-1;
 int oldkey=-1;
 
@@ -26,11 +27,18 @@ void setup() {
   //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)
    lcd.clear();
   lcd.printIn("KEYPAD testing... pressing");
+
+  Serial.begin(115200);
+  Serial.println("Keypad testing over serial");
 }
 
 void loop() {
 
        adc_key_in = analogRead(0);    // read the value from the sensor  
+
+  if (old_adc != adc_key_in)
+    Serial.println(old_adc = adc_key_in);
+
   digitalWrite(13, HIGH);  
   key = get_key(adc_key_in);                   // convert into key press
        
@@ -45,6 +53,10 @@ void loop() {
       if (key >=0){
       lcd.cursorTo(2, 0);  //line=2, x=0
                        lcd.printIn(msgs[key]);
+        Serial.print("adc=");
+        Serial.print(adc_key_in);
+        Serial.print(" key=");
+        Serial.println(key);
       }
     }
   }
@@ -76,4 +88,4 @@ int get_key(unsigned int input)
         k = -1;     // No valid key pressed
     
     return k;
-}\r
+}