Hi, I am trying to change the password that allows the servo motor to rotate, but i'm getting an error message.I really need your help, because i have tried all that i could but havn't got a solution.
Here is my code
#include <Keypad.h>
#include <Servo.h>
#include <Password.h>
#include <EEPROM.h>
int addr =0; //the current address in the EEPROM
// Set up keypad variables:
Password password =Password("756");
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
// Set up servo variables:
int angle = 0; // Angle in degrees to position servo [0-180]
Servo servo; // Create the servo object
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {3, 8, 7, 5};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {4, 2, 6 };
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
Serial.begin(9600); // Start up serial comms
servo.attach(11); // Attaches the servo pin 11
keypad.addEventListener(keypadEvent); //add an event listener
}
void loop() {
keypad.getKey();
servo.write(0);
}
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print(eKey);
switch (eKey){
case '*': checkPassword(); break;
case '#': password.reset();
Serial.println("PLEASE ENTER PASSWORD"); break;
case '0': changePassword();
Serial.println("ENTER NEW PASSWORD");
password.set(neKey)); break;
default: password.append(eKey);
}
}
}
void checkPassword(){
if (password.evaluate()){
Serial.println("PASS CODE SUCCESSFUL");
for(angle=0; angle<180; angle+=1){
servo.write(angle);
delay(15);
}
delay(5000);
for(angle = 180; angle>=1; angle-=1){
servo.write(angle);
delay(15);
}
//Add code to run if it works
}else{
Serial.println("ACCESS DENIED! ,PRESS # TO RETRY ");
//add code to run if it did not work
}
}
void changePassword(KeypadEvent neKey){
if(password.evaluate(){)
switch (keypad.getState()){
case PRESSED:
Serial.print(neKey);
switch (neKey){
case '*': checkPassword(); break;
case '#': password.reset();
Serial.println("PLEASE ENTER PASSWORD"); break;
default: password.append(neKey);
}
}
}
}