the code doesnt have any error but then it isnt working on the product
#include <Keypad.h>
#include<EEPROM.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial Sim900A(9, 10);
LiquidCrystal lcd(14, 15, 16, 17, 18, 19);
char password[5]="1234";
char pass[5],pass1[5];
char tempPass[5];
char customKey=0;
char key_pressed;
const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
// Define the Keymap
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = { 23,25,27,29 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 22,24,26,28, };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
// Create the Keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
uint8_t id = 1;
int i=0;
int c;
int randNumber;
String str_tempPass = "";
String str_randomPass = "";
#define solenoidlock1 1
#define solenoidlock2 2
#define solenoidlock3 3
#define pickbutton 4
#define dropbutton 5
int buttonState = 0;
int buttonState1 = 0;
void setup()
{
lcd.begin(16, 2);
pinMode(solenoidlock1, OUTPUT); //sets solenoid as Output
pinMode(solenoidlock2, OUTPUT); //sets solenoid as Output
pinMode(solenoidlock3, OUTPUT); //sets solenoid as Output
pinMode(pickbutton, INPUT); //sets button as Input
pinMode(dropbutton, INPUT); //sets button as Input
Sim900A.begin(9600); // Setting the baud rate of GSM Module
}
void loop()
{
buttonState = digitalRead(dropbutton);
if (buttonState == HIGH) {
lcd.clear();
char key = customKeypad.getKey();
drop();
}
buttonState1 = digitalRead(pickbutton);
if(buttonState1 == HIGH) {
lcd.clear();
char key = customKeypad.getKey();
pick();
}
}
void drop()
{
char key = customKeypad.getKey();
//use keypad to type the locker
lcd.write("choose 1,2,3");
lcd.setCursor(0, 1);
if (key == '1')
{
digitalWrite(solenoidlock1, HIGH);
delay(1000);
digitalWrite(solenoidlock1,LOW);
delay(5000);
lcd.write("Door Opened");
delay(5000);
lcd.clear();
}
{
digitalWrite(solenoidlock1, LOW);
delay(1000);
digitalWrite(solenoidlock1, HIGH);
lcd.write("Door Closed");
sendMessagelocker1;
}
if (key == '2')
{
digitalWrite(solenoidlock2, HIGH);
delay(1000);
digitalWrite(solenoidlock2,LOW);
delay(5000);
lcd.write("Door Opened");
delay(5000);
lcd.clear();
}
{
digitalWrite(solenoidlock2, LOW);
delay(1000);
digitalWrite(solenoidlock2, HIGH);
lcd.write("Door Closed");
sendMessagelocker2;
}
if (key == '3')
{
digitalWrite(solenoidlock3, HIGH);
delay(1000);
digitalWrite(solenoidlock3,LOW);
delay(5000);
lcd.write("Door Opened");
delay(5000);
lcd.clear();
}
{
digitalWrite(solenoidlock3, LOW);
delay(1000);
digitalWrite(solenoidlock3, HIGH);
lcd.write("Door Closed");
sendMessagelocker1;
}
}
void pick()
{
char key =customKeypad.getKey();
if (key == '1')
{
lcd.print("Enter Pin Code:");
char key = customKeypad.getKey();
if (str_tempPass==str_randomPass)
{
lcd.print("Pin Success!");
lcd.print("locker 1 opening");
digitalWrite(solenoidlock1, LOW);
delay(5000);
digitalWrite(solenoidlock1, HIGH);
lcd.clear();
}
else if (!(str_tempPass==str_randomPass)){
Serial.println("Incorrect Pin!");
}
}
if (key == '2')
{
lcd.print("Enter Pin Code:");
char key = customKeypad.getKey();
if (str_tempPass==str_randomPass)
{
lcd.print("Pin Success!");
lcd.print("locker 1 opening");
digitalWrite(solenoidlock2, LOW);
delay(5000);
digitalWrite(solenoidlock2, HIGH);
lcd.clear();
}
else if (!(str_tempPass==str_randomPass)){
Serial.println("Incorrect Pin!");
}
}
if (key == '3')
{
lcd.print("Enter Pin Code:");
char key = customKeypad.getKey();
if (str_tempPass==str_randomPass)
{
lcd.print("Pin Success!");
lcd.print("locker 1 opening");
digitalWrite(solenoidlock3, LOW);
delay(5000);
digitalWrite(solenoidlock3, HIGH);
lcd.clear();
}
else if (!(str_tempPass==str_randomPass)){
Serial.println("Incorrect Pin!");
}
}
}
void sendMessagelocker1()
{
generatePassword();
Sim900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
Sim900A.println("AT+CMGS=\"+6497116543\"\r"); // Replace x with mobile number
delay(1000);
Sim900A.println("delivery arrived");// The SMS text you want to send
Sim900A.println("package in locker1");// The SMS text you want to send
Sim900A.println("please key in code");// The SMS text you want to send
Sim900A.println(str_tempPass);
delay(100);
Sim900A.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void sendMessagelocker2()
{
generatePassword();
Sim900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
Sim900A.println("AT+CMGS=\"+6497116543\"\r"); // Replace x with mobile number
delay(1000);
Sim900A.println("delivery arrived");// The SMS text you want to send
Sim900A.println("package in locker2");// The SMS text you want to send
Sim900A.println("please key in code");// The SMS text you want to send
Sim900A.println(str_tempPass);
delay(100);
Sim900A.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void sendMessagelocker3()
{
generatePassword();
Sim900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
Sim900A.println("AT+CMGS=\"+6497116543\"\r"); // Replace x with mobile number
delay(1000);
Sim900A.println("delivery arrived");// The SMS text you want to send
Sim900A.println("package in locker3");// The SMS text you want to send
Sim900A.println("please key in code");// The SMS text you want to send
Sim900A.println(str_tempPass);
delay(100);
Sim900A.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
//GENERATE PIN
void generatePassword()
{
randomSeed(analogRead(0));
for (int i = 0; i < 4; i++);
{
randNumber = random(0,9);
str_tempPass = str_tempPass + String(randNumber);
Serial.print(str_tempPass);
}
}