Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- const byte ROWS = 4; //four rows
- const byte COLS = 3; //three columns
- char keys[ROWS][COLS] = {
- {'1','2','3'},
- {'4','5','6'},
- {'7','8','9'},
- {'*','0','#'}
- };
- byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- static char accesscode[7] = {'7', '3', '5', '5', '6', '0', '8'};
- static char code[7] = {'0', '0', '0', '0', '0', '0', '0'};
- int i;
- int ledr = 13;
- int pot = A0;
- int potval = 0;
- int relais1 = 14;
- int relais2 = 15;
- void setup(){
- Serial.begin(9600);
- pinMode(ledr, OUTPUT);
- pinMode(relais1, OUTPUT);
- pinMode(relais2, OUTPUT);
- pinMode(mos, OUTPUT);
- }
- void loop(){
- potval = analogRead(pot);
- Serial.println(potval);
- char key = keypad.getKey();
- int j = 0;
- if(key){
- code[i] = key;
- Serial.println(code[i]);
- i = i + 1;
- if(i == 7){
- while(code[j] == accesscode[j]){
- j = j + 1;
- if(j == 7){
- Serial.print("Code bon.");
- digitalWrite(relais1, HIGH);
- digitalWrite(relais2, LOW);
- delay(7000);
- digitalWrite(relais1, LOW);
- delay(1000);
- digitalWrite(relais2, HIGH);
- delay(7000);
- digitalWrite(relais2, LOW);
- delay(1000);
- }
- else if(j != 7){
- char code[7] = {'0', '0', '0', '0', '0', '0', '0'};
- }
- }
- }
- }
- if(potval > 485){
- digitalWrite(ledr, LOW);
- }
- /**/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement