Light-Sensing Robot Pet
A small robot that wakes up when the lamp turns on and goes to sleep in the dark.
What I Built
A cardboard pet with a photoresistor for an eye, a buzzer for a voice, and a Python loop watching the brightness. When light crosses a threshold, the pet chirps.
What I Learned
Sensors don't read 'bright' or 'dark' — they read a number. The threshold is a choice the programmer has to make, not something the sensor knows.
Problem I Solved
The pet had to ignore quick flickers from cars driving by the window and only react to steady light. I added a small delay to smooth the readings.
What I Would Improve
Add a second sensor on the other side so the pet knows which direction the light came from and turns to face it.
Code Snippet
pythonimport time
from gpiozero import LightSensor, Buzzer
eye = LightSensor(4)
voice = Buzzer(17)
while True:
if eye.value > 0.6:
voice.beep(0.1, 0.1, n=2)
time.sleep(0.5)Skills Used
Reflection
“Surprised me how the robot reacted faster than I thought a cardboard box ever could.”