The assignment is to design and program a smart device that perform a certain function or solve a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code).
so, I decided to design a smart room that makes alarm when the sun shines and turns on the light when some one enters the room.
Jumper wires
Bread board
Buzzer
Arduino uno
220 ohm resistor
LED
Ultrasonic sensor
LDR sensor
I designed the circuit using tinker cad
First circuit is an ultra sonic sensor "input" &LED "output"
so, if any one comes inside the room the LED turns on.
I connected:
echo on pin 2 "input"
treg on pin 3
the Led on pin 9 "output"
Second circuit is LDR sensor "input" and buzzer "out put"
so, if the sunlight at the morning comes inside the room or the curtains removed the buzzer works as an alarm to wake up.
I connected:
LDR sensor on pin 6 "input" (I used PIR sensor on tinkercad as the LDR is not available)
the buzzer on pin 8 "output"
Diagram circuit for buzzer that works when the sun light comes inside the room "Sunlight alarm"
I wrote the code on Arduino ide for each part and test it using the Arduino cc.
I defined the the ultrasonic sensor & lRD as inputs & led and buzzer as outputs.
If the ultra sonic sensor measures distance less than or equal 6 cm the out put will be on the LED that will be on.
else the Led will be turned off
If the the LDR sensor read high (feels with light ) the buzzer will form a sound other wise the buzzer produces no sound.
I connected the two circuits on one bread board
First part:
The ultrasonic sensor as input ( echo on pin 2 & treg on pin 3 ) and the LED and the resistor with 220 ohm as output (the Led on pin 9).
Second part :
]The LDR sensor as input ( on pin 6 ) and the buzzer as an output ( on pin 8 ).
Because the circuit contains more than ground and more than vcc I connected then an the bread board and finally connected to the Arduino.
Finally I uploaded the code on Arduino.
When someone enters the room the light turns on. when the curtains removed or the light enters the room "sin shines" the buzzer works to wakeup the sleeping person
at the beginning curcuit was not working as I was connecting the LDR module on the analog pin when I changed it and used the digital pin it works.
At the beginning I had some problems on writing the code then by the help of my friend and my instructor I could find the mistakes.
At the beginning of the code there was // so the code was not working as it read as a comment.
I could write my own code in my final project to make any needed function.
I learnt how to search about codes and download any needed library.
Title of Media