This week's assignment was to make a circuit with two inputs, and two outputs. And as the weather changes these days, we face this problem of deciding what to wear when we're going out. I decided to make a device that peeps (using a buzzer) whenever you come across it (IR sensor) and it tells you what to wear ( using an LCD) and also makes lighting (using LEDs) according to the weather(using DHT sensor).
The software used for the assignment:
TinkerCad circuits building and simulation online tool
Arduino IDE
The Hardware:
Arduino uno
IR sensor
Jumpers wires
Buzzer (5V)
Breadboard
LCD screen
3 LEDs
DHT sensor
5V adaptor
Cardboard
double-sided tape
I dragged and dropped the components of the circuit in the design workspace in Tinker CAD
1- I connected the power supply to the breadboard
2- Then I made a common GND from the Arduino
3- I connected the DHT sensor to the breadboard (VCC , GND) and the signal o the Arduino. I made the same to the IR sensor
4- I connected the LCD screen to the Arduino and the breadboard:
Where GND connected to the negative part of the breadboard
VCC is connected to the positive part
SDA to A4 pin on the Arduino
SCL to A5 pin on the Arduino
5- The buzzer is connected to the Arduino and the breadboard where the Anode is connected to pin 6 and the cathode is connected to the negative part of the breadboard
6- I wired the 3 LEDs cathode with 220 ohm resistors on the breadboard, the other part of the resistor is connected to the ground. and the LED's anode is connected to the Arduino pins.
Coding:
I defined the DHT sensor library, and the LCD library. I made integers of the LEDs pins so I can easily use them
I then set my inputs and outputs. and I also made the actions I want the device to start with
I made a statement to clear the LCD, turn off all the LEDs, and to read the humidity and temperature.
Then I made an If statement that checks if someone is in front of the device or not .
If someone walks across the device the buzzer peeps for seconds to grab his attention
the the if statement checks the DHT sensor readings
If it's hot, the red LED in on and it the LCD screen shows "it's hot outside sign"..
It also checks the other weather condition's according to the sensor reading.
I faced a coding problem as I didn't know that I'm able to use an IF statement into another one, to check the first one before proceeding through the rest of the code.
. then I asked Google. it was great to learn more about when to use if statements and how to use them here's the documentation I learned from:
I got more confident with writing code and debugging and I guess it will really help me later with my final project .
I made a smart home with my friend AHMED ASHMAWY , where the lights and fans can be controlled automatically or manually.