#include <Keypad.h>
#include <Servo.h>
#define Password_Length 4;
static const int spy = 0;
static const int analyst = 0;
static const int director = 0;
int sensor = 11;
int sensorState = LOW;
Servo myservo;
int servoPin = 10;
int position = 0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = { //define the symbols on the buttons of the keypads
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //initialize an instance of class NewKeypad
byte value = 0; // Will not go above 255 using byte identifier - use int for higher
char customKey = 0;
void setup() {
myservo.attach(10);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop(){
sensorState = digitalRead(sensor);
while (digitalRead(sensor)==HIGH){
Serial.println("welcome");
delay(10);
}
while(digitalRead(sensor)==LOW){
Serial.println("");
}
customKey = customKeypad.getKey();
if (customKey != NO_KEY) {
if ((customKey >= '0') && (customKey<='9')) {
value = value*10;
value = value + customKey - '0';
}
if(customKey =='#') {
Serial.println(value);
value = 0;
}
}
}
My servo doesn't respond to this program.