This week assignment's idea is building and programing a smart circuit using an Arduino UNO which reads a signal from an input component to control an action component using Code Blocks.
As i love lights and i didn't love to sleep in the dark , My idea is making a lamp emits different colors when the lights off.
I used tinker cad to design and simulate the circuit , the resistor calculator to calculate the ohm of resistor and Arduino IDE to download the code on the Arduino UNO.
Materials : I used a 5 volt adapter , Arduino UNO , 3 pin Photo resistor LDR Module , RGB led , 3 resistors 220 ohm , Mini breadboard , Jumper wires , cardboard , one sheet of a4 paper .
Arduino IDE
Tinker cad
Resistor calculator
Tinkercad circuit
I start to design and simulate the circuit using Tinker cad to make sure that everything work.
I connect photoresistor terminal 1 to pin 8 and i also put 4.7kohm and take another wire from terminal 1 and connected it with GND then i connect terminal 2 to Arduino vcc to 5v pin , next i put RGB led and connected the 3 terminals (red,blue,green) with 3 resistors (220 ohm) and connect the red terminal with pin 7 , the blue terminal with pin 6 , the green terminal with pin 5 then connect the cathode terminal to GND pin.
Code blocks (1)
Code blocks (3)
Code blocks (2)
I used if condition to read the digital pin 8 that connected with the photoresistor led if it low ( light is off ) :
1- Blue color will emits for 15 sec
2-Green color will emits for 15 sec
3- Red color will emits for 15 sec
4- purple color will emits for 15 sec
5- yellow color will emits for 15 sec |
6- cyan color will emits for15 sec
Then in else i make all pins = low to turn off all colors if the light is on.
I connect the LDR sensor vcc to 5v pin in Arduino and GND to GND pin and Do pin to pin 8 and the RGB led the same i do in tinkercad. After i made my circuit i use cardboard to put all my components in it and i made a origami lamp with A4 paper sheet to make it more beautiful and be able to use it in decoration.
I asked Mohamed Adel about how IR sensor work because it didn't make its function right and he suggested me to use the photo resistor sensor and i didn't know what it is but after he told me i realized that this sensor will be more better for my idea , also he helped me to know how i find and use it in tinkercad.
After i make the circuit and code i realized that if i turn lights on all colors will emits and will not stop until the loop finish. Then i think that if i use if condition before every color it will see if the light off it will continue emit color lights and if the light turned on it will stop emit color lights.
part 1
Part 2
Part 3
From this week i was thinking about adding lights and photo resistor sensor to make my project more beautiful.
I enjoyed the end of week session exercise as we made a smart waving hand and i loved the ultrasonic sensor.
Waving hand using servo motor and potentiometer.
simulation on tinker cad