1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| import time
import RPi.GPIO as io
io.setmode(io.BCM)
pir_pin = 24
power_pin = 23
io.setup(pir_pin, io.IN)
io.setup(power_pin, io.OUT)
io.output(power_pin, False)
while True:
if io.input(pir_pin):
print("POWER ON")
io.output(power_pin, True)
time.sleep(20);
print("POWER OFF")
io.output(power_pin, False)
time.sleep(5)
time.sleep(1)
|