#include //http://www.arduino.cc/playground/uploads/Code/Password.zip #include //http://www.arduino.cc/playground/uploads/Code/Keypad.zip #include #include LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display boolean triggered; byte armed, oldarmed, firing; Password password = Password( "1234" ); byte blah,bleh; const byte ROWS = 4; // Four rows const byte COLS = 3; // columns // Define the Keymap char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins. byte rowPins[ROWS] = { 5, 4, 3, 2 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins. byte colPins[COLS] = { 8, 7, 6 }; // Create the Keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); void setup(){ Serial.begin(9600); lcd.init(); lcd.backlight(); keypad.addEventListener(keypadEvent); //add an event listener for this keypad } void loop(){ if(!triggered){ keypad.getKey(); } else{ checkarmed(); writearmed(); blah = ((byte)map(analogRead(A0), 0, 1024, 45, 105)); bleh = ((byte)map(analogRead(A1), 0, 1024, 180, 0)); Serial.print(" 900) armed = armed | 0x05; else if(left>800) armed = armed | 0x01; else if(left>100) armed = armed | 0x04; else armed = armed | 0x00; if(right > 900) armed = armed | 0x0a; else if(right>800) armed = armed | 0x02; else if(right>100) armed = armed | 0x08; else armed = armed | 0x00; firing = 0; if(digitalRead(12)) firing = firing | 0x03; if(digitalRead(13)) firing = firing | 0x0C; } void writearmed(){ if(oldarmed != armed) { lcd.clear(); lcd.setCursor(0,0); if(armed & 0x01) lcd.print("ARMED 1"); lcd.setCursor(8,0); if(armed & 0x02) lcd.print("ARMED 2"); lcd.setCursor(0,1); if(armed & 0x04) lcd.print("ARMED 3"); lcd.setCursor(8,1); if(armed & 0x08) lcd.print("ARMED 4"); } oldarmed = armed; }