I have a Velleman 12 keys common output pin keypad. I have written the code to detect the numbers coming in and it works fine, printing the right number on the serial monitor.
The problem I'm having is that I need it to recognize a string of numbers. I need to input 52# and then output an led sequence. I have not been able to find anything using the non-matrix keypad.
Please help! Below is the code I'm currently using to read the input from the keypad.
void setup(){
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
}
void loop(){
int three = digitalRead(2); // keypad pin 2
int seven = digitalRead(3); // keypad pin 3
int four = digitalRead(4); // keypad pin 4
int one = digitalRead(5); // keypad pin 5
int zero = digitalRead(6); // keypad pin 6
int eight = digitalRead(7); // keypad pin 7
int five = digitalRead(8); // keypad pin 8
int two = digitalRead(9); // keypad pin 9
int pound = digitalRead(10); // keypad pin 10
int nine = digitalRead(11); // keypad pin 11
int six = digitalRead(12); // keypad pin 12
if(seven==LOW){Serial.println(7);}
if(four==LOW){ Serial.println(4); }
if(one==LOW){ Serial.println(1); }
if(zero==LOW){ Serial.println(0); }
if(eight==LOW){ Serial.println(8); }
if(five==LOW){ Serial.println(5); }
if(two==LOW){ Serial.println(2); }
if (pound==LOW){ Serial.println("#"); }
if(nine==LOW){ Serial.println(9); }
if(six==LOW){ Serial.println(6); }
if (three==LOW) {Serial.println(3);}
}