Raspberry Pi practice problem · Projects
Garage stop light
EasyBudget $10Python · gpiozero
Help a driver park: a distance sensor on the garage wall (TRIG GPIO23, ECHO GPIO24, 5 V) and two LEDs: green on GPIO17, red on GPIO27.
- car 50 cm or farther away: green on, red off
- car closer than 50 cm: red on, green off
The test car is at 150 cm, 80 cm at 2 s, 30 cm at 4 s, and leaves (150 cm) at 6 s.
The HC-SR04's ECHO is a 5 V signal: either buy the Distance sensor module kit (with its divider) or add a 1 kΩ / 2 kΩ divider yourself.