use of pir motion detector for lightening
This week I tried to make a project with 2 input and one output. In this project I used led as an output which acts as the inner light of a room and it can be controlled with keypad password of the door room or with ir sensor that make the led on whenever anyone in the room. I care about this project because I may use 2 inputs in my final project specially keypad.
software:
arduino
tinkercad
materials: arduino uno
ir sensor(input)
led(output)
lcd(output)
small bread board
cardboard, scissors
jumpers (male -male & male - female)
arduino
keypad
I made the circuit as shown:
I connected:
ir sensor to pin 12, 5v and GND as an input component.
keypad to pins from 3 to 9 as input component.
lcd to 3.3v, GND, SCL to pin A5, SDA to pin A4 as output.
LED to pin 2 and GND as output
first: I made the code with ir sensor alone and tested it
pin 12 for signal of ir and pin 2 for led
the led is on when the sensor read is low
In void setup: I made pin 12 which connected to ir signal as input and pin 2 which connected to led as output.
In void loop: I used if function to make the led on when the sensor read is low and off when high.
second: I made the keypad and lcd code as explained in the week tutorial using the keypad library
-I included the library of keypad
-write the type of keypad and numbers in rows and columns as opposite
-to take an input value from keypad; we added variable called digit1 and its type is char and repeated this for numbers we need to add and put counter started from 1 to the end number
-'int state=0' to read the state of the led and make it to the opposite state ;eg(if high, it will turn into low)
I merged them to make the led turn on whether the ir sensor read low or the pass is correct
coding
and the file of total code is below
I connected the circuit as follow:
keypad to pin from 3 to9
lcd as its data sheet
I uploadded the code
I used cardboard to make enclosure
I made the code that read ir sensor as follow:
if ( digitalRead(12) == HIGH) {
and the circuit wasn't operating , Mohanad told me to make HIGH LOW
ir read
keypad coding
I think I will use the keypad in finall project
how to code keypad and print it on lcd