light with motion sensor
This week assignment is to Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component (Sensor, Switch, or variable resistor) to control an action component (Motor, Buzzer, LED...etc) using Code Blocks .
i saw this idea at a movie where the lights is on just when there is a motion .
so i decided to build a program simulate the same idea " light with motion sensor.
Software:
-Tinker-cad to test the circuit and coding.
-Arduino IDE to upload the code.
Materials:
-Arduino UNO
-IR sensor.
-Breadboard
-Jumper wires.
-Red LED.
-220 Ω resistors.
-9v power adapter.
circuit components
tinker cad circuit
Using Tinkercad I started adding the components on the breadboard and connecting it to the power source and Arduino UNO board.
Connected the PIR sensor as follows:
signal to pin 5.
power to positive of power source.
ground to negative of power source.
connected the led as follows:
terminal 1 to ground of power source.
terminal 2 to the terminal 1 of the resistor.
terminal 2 of the resistor to pin 6 at Arduino.
connected Arduino as follows:
GND to ground of power source.
VIN to positive of power source.
Note:
Arduino is powered using 6v to 12 v, 5v will not be enough.
circuit description:
-when power is on the IR sensor start its work .
-when there is any object at the range of sensor then the input data to the Arduino equals 1 .
-when the output data from the sensor equals 1 then the input data to pin 6 equals 1 or "high" so the led is on, and otherwise the led is off.
arduino code
code blocks
Demo Video
components
cicuit
i put the PIR == 1 at Arduino code and the led is not working, so i print the PIR read at serial monitor and i find that when it reads 0 that means there is something close, so i modified the code making the PIR == 0 the led is on.
Title of Media
coding using Arduino will help me at my final project since i will use it to control the different electronic components to make the required mition from it.
make an device we see around us every day by myself was a cool thing acuelly.