0

I need help with my code

Here's the code itself

#include <Keypad.h>

#include <LiquidCrystal.h>

const byte numRows= 4;
const byte numCols= 4;
int code= 1234;
int input= 0;

char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte rowPins[numRows] = {9,8,7,6};
byte colPins[numCols]= {5,4,3,2};

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup()
{
Serial.begin(9600);
}

void loop()
{
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
Serial.println(input);
Serial.println(keypressed);
if (keypressed != 'A' || keypressed != 'B' || keypressed != 'C' || keypressed != 'D' || keypressed != '#' || keypressed != '*'){
input = (input * 10 + keypressed);
}

I am trying to have it chain together the numbers pressed on a keypad so I can have it check that against the code 1234 and check for a match but it isn't chaining the numbers onto the end of the input variable

0 comments

Please sign in to leave a comment.