Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- long value = 0;
- const byte ROWS = 4; //four rows
- const byte COLS = 4; //four columns
- char keys[ROWS][COLS] = {
- {'1', '4', '7', '*'},
- {'2', '5', '8', '0'},
- {'3', '6', '9', '#'},
- {'A', 'B', 'C', 'D'}
- };
- byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {11, 10, 9, 8}; //connect to the column pinouts of the keypad
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- char key = keypad.getKey();
- if (key == 'A' || key == 'B' || key == 'C' || key == 'D') {
- Serial.print("");
- }
- else Serial.print(key);
- delay(1);
- if (key != NO_KEY)
- {
- if ( (key >= '0') && (key <= '9') )
- {
- value = value * 10;
- value = value + key - '0';
- }
- if ( key == 'A' )
- {
- Serial.println();
- Serial.println(value);
- // Remove this line and add it to the sensor value checker complete
- value = 0; //Now reset ready for next input
- }
- }
- if (key == 'B')
- {
- value = 0; //Now reset ready for next input
- Serial.println();
- Serial.println("Enter A New Number Please:");
- }
- if (key == 'C')
- {
- // Do whatever you like
- //digitalWrite(ValvePin, LOW); // if relay is Active LOW
- }
- if (key == 'D')
- {
- // Do whatever you like
- //digitalWrite(ValvePin, HIGH); // if relay is Active LOW
- }
- }//end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement