This week's assignment was to design and program a smart device that performs a certain function or solves a problem, using the program Arduino to read signals from multiple input components to control multiple action components, using Arduino C (Text Code).
My idea for this week was to upgrade week 6 as it was about rotating the joint when the LDR sensor senses the light which is related to my final project
The upgrade is to make the servo revolve which will revolve the louvers according to the LDR & temp sensor and also a manual mode to rotate the servo
Arduino Uno
LDR sensor
Temp. sensor
1 Slide switch (Represents the Automation Switch)
1 ON/OFF Switch (servo Switch)
servo
breadboard
jumper male-male & female male
white foam for the box
cutter to make openings for the switches
blue sticky note to indicate the movement of servo
I start drawing a diagram to know the sequence of the code
so the first thing was a switch to control the automatic & manual modes then according to the reading if the automatic mode is on
determine the sensor's reads
and rotate the servo according to this read
and turn on the lamp
if the manual mode is on
neglect all the reads
rotate servo
Parts ( LDR sensor , servo , temp sensor, slide switch , push button and lamp )
for the LDR & temp. senor connecting the GND with the -ve on a breadboard, the VN with the +ve in the breadboard, and the third pin in Arduino.
for the push button connecting one terminal with the +ve of the breadboard and the other with a pin in Arduino
for the slide switch connecting one terminal with the +ve, -ve of the breadboard and the other with pin in Arduino
for servo connecting the pin in Arduino and the other 2 in the breadboard
for lamp connecting the pin in Arduino and the other in the breadboard
Download the DHT11 library for temp. sensor and include it
searching for The code of servo motor
define the servo (#include <Servo.h>) and DHT (#include <DFRobot_DHT11.h>) and lamp their Arduino pins
define the pins for { LDR, 1 Slide switch (Represents the Automation Switch),1 ON/OFF Switch (servo Switch)}
choose the pin mode ( input, output, pullup)
the sequence of the code as I showed in the diagram
I used IF condition for the modes first then for the LDR& temp. sensor for rotating the servo and turn on the lamp
The Manual mode
I used IF condition to check the servo switch and rotate the servo
I started to download the code on Arduino
for the LDR & temp. senor connecting the GND with the -ve on a breadboard, the VN with the +ve in the breadboard, and the third pin in Arduino.
for the push button connecting one terminal with the +ve of the breadboard and the other with a pin in Arduino
for the slide switch connecting one terminal with the +ve, -ve of the breadboard and the other with pin in Arduino
for servo connecting the pin in Arduino and the other 2 in the breadboard
for lamp connecting the pin in Arduino and the other in the breadboard
connect all components with each other and check their functionality
first i tried the servo alone to test it functionality with the modes because it is the main part in my final project
I replaced the 1 Slide switch (Which represents the Automation Switch), and 1 ON/OFF Switch (servo Switch) in the breadboard with external switches using crocodiles to do its function in the box, and the lamp is inside
I couldn't include the DHT library to Arduino IDE, the problem was the window read it as a virus
The solution is to turn off windows security
The manual mechanism of my final project
How the mechanism manually works using electronics and responding to sunlight
In the offline session, we make a simple smart home in which we can control a fan and a lamb in manual or automatic mode. I Learned how to control motors by an H-bridge module and a relay module
It was helpful as my teammates Ahmed Atef and Ahmed Reda explain the code sequence and how the components will work together in an easy way