7.Night light
Case Description
The night light automatically turns on through the combined action of light sensor and PIR (Passive Infrared) detection.
###Key Knowledge Points
How to use the Sugar light sensor module
How to use the Sugar PIR (Passive Infrared) module
##Case Implementation
###Structural Assembly Night light.pdf
###Circuit Connection
- Connect the light sensor module to the Robotbit P0 terminal block.
- Connect the PIR module to the Robotbit P1 terminal block.
- Connect the LED module to the Robotbit P2 terminal block.
###Programming 1、The PIR module essentially functions as a button module, so the program needs to initialize it with a pull-up setting.
2、When both conditions are met—light value less than 400 and PIR triggered (Pin1=1)—the LED module turns on (Pin2=1) and remains lit for 3 seconds.
