For this week I went for automatic blinds that adjust based on light using an LDR sensor and a servo motor.
It’s a simple way to explore smart home automation and improve energy efficiency.
Electronics
Arduino Uno
Servo Motor
Male to Male Jumpers
Male to Female Jumpers
LDR Sensor
Connections on TinkerCad
sensor connections :
the photoresistor ( equivalent to the LDR sensor we have ) one of its terminals to A0 which is analog pin
330 ohm resistor on the left terminal then to GND
the right terminal connected to the 5V
servo motor connections :
the signal wire to pin 9
the power wire to 5V
the ground wire to GND
Code Blocks on TinkerCad
go to Variables --> Create Variable --> lightLevel (variable name)
set the variable to read analog pin A0 (where we have our sensor)
go to Control --> Insert if - else block
go to Math --> Insert the diamond shape with 2 ovals
get lightLevel from Variables --> insert it in the 1st oval
set it ">" greater than sign , 200
then
insert Output --> rotate servo pin 9 (where we connected the servo) to 90 degrees
insert wait 100 ms
else : rotate servo on pin 9 to 0 degrees ( means when no light do not rotate stay in place )
Simulation on TinkerCad
Final Outcome Explanation :
the servo motor rotates by 90 degrees when the LDR sensor is met with light when light is not strong enought the servo goes back to its orginal place at 0 degrees
Difference between LDR Module sensor and Photoresistor on TinkerCad
The difference between the connections made on TinkerCad and the ones on the breadboard is , the LDR sensor we have is LDR module which measure the resistance by itself. While the photoresistor on TinkerCad acts as a variable resistor where we have to limit its resistance optimally by 10k ohms but 33o ohms is fine as well.
chatgpt
makers electronics website when you search for LDR module
Video Recording of final outcome
One challenge I faced was that the LDR sensor in our kit wasn't the same as the one in Tinkercad. However, after some research, I learned the difference and how to connect them. Another challenge was that in Tinkercad, there were two wires connected to the 5V pin on the Arduino, but on a real breadboard, we can't fit two wires into one pin. I asked ChatGPT about it, and the solution is to connect the 5V pin to the +ve rail and then connect both wires to the +ve rail instead.