I used tinkercad to simulate the circuit
I used
bread board
5v adaptor
arduino
crocodile wires
BLUTOOTH MODULE
LAMP 12V
RELAY MODULE
GUI ON ANDROID DEVICE
LCD SECREEN
KEYPAD
SERVO MOTOR
1k resistor
530 ohm resistor
arduino ide soft ware
Simulating the circuit on tinker cad and photoshop
I connected the Bluetooth module with the divider circuit and Arduino pins 0/1 and the GND + 5v
then connected the servo with pin 11 on Arduino
also connected the lamp with the relay module and the adaptor
also connected the relay module with pin 10 on Arduino
then connected the keypad with Arduino on pins 3/4/5/6/7/8/9
then I started coding at first I wrote the code of the keypad then added the servo and the relay module then added the Bluetooth module
I programmed the Arduino to work on digital and manual mode on digital mode when I write the right password it will print on the screen that this pass is right and play the servo and the lamp also it will do the opposite when the password is wrong
in the digital mode I will be able to control the lamp and the servo with A GUI on an android device and print the actions on the LCD
#include <Keypad.h>
#include <Servo.h>
Servo lock;
char incomingData = '0' ;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int ROW_NUM = 4;
const int COLUMN_NUM =3;
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte pin_rows[ROW_NUM] = {9, 8, 7, 6};
byte pin_column[COLUMN_NUM] = {5, 4, 3};
char digit1;
char digit2;
char digit3;
char digit4;
char enter;
int counter =1;
int state = 0;
byte customChar1[8] = {
0b00000,
0b00110,
0b00110,
0b00000,
0b00000,
0b01111,
0b00111,
0b00011
};
byte customChar2[8] = {
0b00000,
0b01100,
0b01100,
0b00000,
0b00000,
0b11110,
0b11100,
0b11000
};
byte customChar3[8] = {
0b00000,
0b00000,
0b00100,
0b01100,
0b11111,
0b01100,
0b00100,
0b00000
};
byte customChar4[8] = {
0b00000,
0b00000,
0b00100,
0b00110,
0b11111,
0b00110,
0b00100,
0b00000
};
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.createChar(1, customChar1);
lcd.createChar(2, customChar2);
lcd.createChar(3, customChar3);
lcd.createChar(4, customChar4);
lock.attach(11);
lock.write(0);
pinMode(10, OUTPUT);
}
void loop()
{
if (Serial.available() == 0);{
incomingData = Serial.read();
if (incomingData == '0') {
lock.write(90);
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("DOOR OPEN");
}
else if (incomingData == '1') {
lock.write(0);
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("DOOR CLOSE");
}
else if (incomingData == '2') {
digitalWrite(10, HIGH);
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("lights on");
}
else if (incomingData == '3') {
digitalWrite(10, LOW);
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("lights OFF");
}
else {
char key = keypad.getKey();
if (key) {
if ( counter == 1) {digit1 = key;}
if ( counter == 2) {digit2 = key;}
if ( counter == 3) {digit3 = key;}
if ( counter == 4) {digit4 = key;}
if ( counter == 5) {enter = key;}
counter++;
}
}
if (counter ==6){
switch (enter){
case '#':
if ( digit1 == '7' && digit2 == '7' && digit3 == '3' && digit4 == '5'){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("correct pass");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.write((byte)1);
lcd.setCursor(1, 0);
lcd.write((byte)2);
lcd.setCursor(2, 0);
lcd.print("welcome back");
lcd.setCursor(2, 1);
lcd.print("DOOR OPEN");
lcd.setCursor(11, 1);
lcd.write((byte)3);
lcd.setCursor(12, 1);
lcd.write((byte)4);
if (state == 0){
lock.write(90);
state = 1;
digitalWrite(10, HIGH);
}
else {lock.write(0);
state = 0;
digitalWrite(10, LOW);
}
}
else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("wrong pass");
digitalWrite(10, LOW);
}
break;
default:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("wrong enter key ('#')");
}
digit1 = NULL;
digit2 = NULL;
digit3 = NULL;
digit4 = NULL;
enter = NULL;
counter = 1;
}
}
}
The circuit works on two modes a manual and digital mode
Manual mode:-
Works by entering the password and the servo and the lamb will open after entering the right password
When I write the correct password " correct password " will be printed on the screen then " welcome back with a smiley face will be printed after that".
If the password is wrong " the wrong password" will be printed on the screen.
Digital Mode :-
Works by using a mobile phone to control the circuit like when I send 0 from the android device the door(servo) will open when I enter two the door will be closed when I send 2 the lamp will be open and when I send 4 the lamp will be closed
after any action is sent from the mobile, the action will be printed on the screen.
While using processing I couldn't find the drivers like in the videos but when I asked on slack I found out that the name was different not like the names on the videos (com3/com4/ com 5)
I wanted to make a randomizer that prints its value on the LCD directly but I couldn't do that without using the serial monitor but it worked anyway
In the hackathon the robot arm after we assembled the circuit wasn't working very well the servo motors stopped working and didn't accept any order from the android device.
so we thought the problem was from the circuit so we assembled it again and also made sure that only our module was working and that the right module was connected to a device and it worked very well after that
I think it will be nice for the final project to be controlled by an android device.
The robot arms I assembled and programmed with my teammates in the hackathon it was cool and interesting.
In the hackathon, this weak my and my teammates Amir and Nadine programmed and assembled a robot arm that we can control with an android device