#include // This Arduino sketch is a demo to the 'Arduino Keypad' App for Android devices (Both created by installtekz.com) // Use a virtual keypad over Bluetooth communication as a substitute for the physical hardware kaypad // // You are free to do as you wish with this code. // // Enter the password: '123' followed by the '#' key to validate the password. // Open the Serial Monitor to check functionality (Open 'Tools>Serial Monitor' in Arduino IDE) or simply look at the LCD display :) // '*' will reset your password guess // ################################################### Incoming Text Strings From The Arduino Keypad App: ########################################## // 0,1,2,3,4,5,6,7,8,9,A,B,C,D,*,# // ################################################################################################################################################# LiquidCrystal lcd(12, 11, 5, 4, 3, 2); byte sad[8] = { B00000, B01010, B01010, B00000, B01110, B10001, B00000, B00000 }; byte tick[8] = { B00000, B00001, B00011, B10110, B11100, B01000, B00000, B00000 }; String inbound; String password = "123"; String guess = ""; void resetGuess() { guess = ""; } void checkPassword() { if (guess == password){ // Enter your successful password code here.. Serial.println("CORRECT Password!"); lcd.setCursor(0,1); lcd.print("CORRECT! "); lcd.write(byte(1)); delay(2000); resetGuess(); } else { // Enter your failed password code here.. Serial.println("WRONG Password!"); lcd.setCursor(0,1); lcd.print("WRONG "); lcd.write(byte(0)); delay(2000); resetGuess(); } } void setup() { Serial.begin(9600); lcd.createChar(0, sad); lcd.createChar(1, tick); lcd.begin(16, 2); } void loop() { while(Serial.available()) { delay(50); char c=Serial.read(); inbound+=c; } if (inbound.length()>0) { if (inbound == "#") { // Enter checkPassword(); } else if (inbound == "*") { // Reset resetGuess(); } else { guess+=inbound; } Serial.println("Key Pressed: " + inbound + " Current Guess: " + guess); lcd.clear(); lcd.home(); lcd.print("Key Pressed: " + inbound); inbound=""; } }