So I'm trying to get this lockpad to work and the lights aren't lighting up. We are using the arduino Mega 2560 board.
Here is our code
#include <Keypad.h>
char* password = "123";
int position = 0;
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS]
{
{'#','0','*'},
{'9','8','7'},
{'6','5','4'},
{'3','2','1'}
};
byte rowPins[ROWS] = {5,6,7,8};
byte colPins[COLS] = {2,3,4};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int redLED = 12;
int greenLED = 13;
void setLocked(bool locked)
{
if (locked)
{
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, LOW);
}
else
{
digitalWrite(redLED, LOW);
digitalWrite(greenLED, HIGH);
}
}
void setup(){
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
setLocked(true);
}
void loop (){
char key = keypad.getKey();
if (key == '*'||key == '#')
position = 0;
setLocked(true);
if(key == password[position]){
position++; //check password go to next spot on list
}
if(position == 3){
setLocked(false);
}
delay(100);
}
I will try to get a picture of the wiring up later. What is wrong? What would you do?
Dogs on a plane