Question
Coding for password of circuit breaker , means that the circuit will open when i enter the right password and it will closed if if
Coding for password of circuit breaker , means that the circuit will open when i enter the right password and it will closed if if wrote the wrong one. so every thing is in control based on the password entering on the keyboard ( I tried many times but give me error and i dont know whats the mistake ) #include #include #include #include "SIM900.h" #include SoftwareSerial mySerial(2,3); #include "sms.h" SMSGSM sms; LiquidCrystal lcd(11,9,8,7,6,5); char password[4]; char pass[4],pass1[4]; int i=0; char customKey=0; const byte ROWS = 4; //four rows const byte COLS = 3; //three columns char hexaKeys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; byte rowPins[ROWS] = {4,A5,A4,A3}; // the row pinouts of the keypad byte colPins[COLS] = {A2,A1,A0}; // the column pinouts of the keypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); int buzzer = 10; int m13=13; int k=1; int numdata; boolean started=false; char smsbuffer[160]; char n[20]; void setup() { Serial.begin(9600); //Serial connection delay(2000); if (gsm.begin(9600)){ lcd.print("READY"); delay(1000); started=true; } else Serial.println(" status=IDLE"); if(started){ //Enable this two lines if you want to send an SMS. //if (sms.SendSMS("3471234567", "Arduino SMS")) //Serial.println(" SMS sent OK"); } lcd.begin(16,2); pinMode(led, OUTPUT); pinMode(buzzer, OUTPUT); pinMode(m2,OUTPUT); pinMode(m13,OUTPUT); lcd.print(" Electronic "); lcd.setCursor(0,1); lcd.print(" Keypad Lock "); delay(2000); lcd.clear(); lcd.print("Enter Password:"); lcd.setCursor(0,1); for(int j=0;j<4;j++) EEPROM.write(j, j+49); for(int j=0;j<4;j++) pass[j]=EEPROM.read(j); } void loop() { customKey = customKeypad.getKey(); if(customKey=='*'&&k==2){ lcd.print(" GSM module"); gsmmm(); } if(customKey=='#') change(); if (customKey){ password[i++]=customKey; lcd.print(customKey); } if(i==4){ delay(200); for(int j=0;j<4;j++) pass[j]=EEPROM.read(j); if(!(strncmp(password, pass,4))){ digitalWrite(led, HIGH); lcd.clear(); lcd.print("Password Accepted"); delay(2000); if(k==1){ digitalWrite(m13,HIGH); k++; } else{ digitalWrite(m13,LOW); k--; } lcd.setCursor(0,1); lcd.print("#Change Password"); delay(2000); lcd.clear(); lcd.print("Enter Password:"); lcd.setCursor(0,1); i=0; } else{ digitalWrite(buzzer, HIGH); lcd.clear(); lcd.print("Access Denied..."); lcd.setCursor(0,1); lcd.print("#Change Password"); delay(2000); lcd.clear(); lcd.print("Enter Password:"); lcd.setCursor(0,1); i=0; digitalWrite(buzzer, LOW); }}} void change() { int j=0; lcd.clear(); lcd.print("Current Password"); lcd.setCursor(0,1); while(j<4){ char key=customKeypad.getKey(); if(key){ pass1[j++]=key; lcd.print(key); } key=0; } delay(500); if((strncmp(pass1, pass, 4))){ lcd.clear(); lcd.print("Wrong Password.."); lcd.setCursor(0,1); lcd.print("Better Luck Again"); delay(1000); } else{ j=0; lcd.clear(); lcd.print("Enter New Passk:"); lcd.setCursor(0,1); while(j<4){ char key=customKeypad.getKey(); if(key){ pass[j]=key; lcd.print(key); EEPROM.write(j,key); j++; }} lcd.print(" Done......"); delay(1000); } lcd.clear(); lcd.print("Enter Ur Passk:"); lcd.setCursor(0,1); customKey=0; } void gsmmm () { while(k){ if(started){ //Read if there are messages on SIM card and print them. if(gsm.readSMS(smsbuffer, 160, n, 20)){ Serial.println(n); Serial.println(smsbuffer); if(!(strncmp(smsbuffer, pass,4))) { digitalWrite(m13,LOW); k--; customKey=0; lcd.print("Enter password"); break; } else{ if(!(strncmp(smsbuffer,"off",3))){ customKey=0; break; } else{ Serial.println("wrong pass"); mySerial.println("AT+CMGF=1"); //the GSM Module in Text Mode delay(1000); // Delay of 1000 milli seconds or 1 second mySerial.println("AT+CMGS=\"00249900671917\" "); delay(1000); mySerial.println("wrong password");// The SMS text you want to send delay(100); mySerial.println((char)26);// ASCII code of CTRL+Z delay(1000); }}}}}}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started