2025-07-30 03:19:44 +00:00
|
|
|
import RPi.GPIO as io
|
|
|
|
import time
|
|
|
|
|
|
|
|
io.setmode(io.BCM)
|
|
|
|
|
|
|
|
|
2025-07-30 03:24:39 +00:00
|
|
|
class Pin:
|
|
|
|
def __init__(self, num, off=io.HIGH):
|
|
|
|
self.num = num
|
|
|
|
self.off = off
|
|
|
|
|
2025-07-30 03:25:01 +00:00
|
|
|
def setup(self):
|
2025-07-30 03:24:39 +00:00
|
|
|
io.setup(self.pin, io.OUT)
|
2025-07-30 03:19:44 +00:00
|
|
|
|
2025-07-30 03:24:39 +00:00
|
|
|
def off(self):
|
|
|
|
io.output(self.pin, self.off)
|
2025-07-30 03:19:44 +00:00
|
|
|
|
2025-07-30 03:24:39 +00:00
|
|
|
def on(self):
|
|
|
|
io.output(self.pin, io.LOW if self.off == io.HIGH else io.HIGH)
|
2025-07-30 03:19:44 +00:00
|
|
|
|
2025-07-30 03:24:39 +00:00
|
|
|
pins = {
|
|
|
|
"red": Pin(27),
|
|
|
|
"yellow": Pin(22),
|
|
|
|
"green": Pin(24),
|
|
|
|
"blue": Pin(23),
|
|
|
|
}
|
2025-07-30 03:19:44 +00:00
|
|
|
|
|
|
|
def reset():
|
|
|
|
for name, pin in pins.items():
|
2025-07-30 03:24:39 +00:00
|
|
|
pin.setup()
|
|
|
|
pin.off()
|
|
|
|
pin.on()
|
|
|
|
time.sleep(2)
|
|
|
|
pin.off()
|
2025-07-30 03:19:44 +00:00
|
|
|
|
|
|
|
reset()
|