code runs well using CircuitPython, linted
This commit is contained in:
parent
563867f19d
commit
e874794564
4 changed files with 27 additions and 0 deletions
BIN
Raspberry_Pi_Power_Control/.Raspberry_Pi_Power_Control.py.swp
Normal file
BIN
Raspberry_Pi_Power_Control/.Raspberry_Pi_Power_Control.py.swp
Normal file
Binary file not shown.
BIN
Raspberry_Pi_Power_Control/.eg.py.swp
Normal file
BIN
Raspberry_Pi_Power_Control/.eg.py.swp
Normal file
Binary file not shown.
4
Raspberry_Pi_Power_Control/README.md
Normal file
4
Raspberry_Pi_Power_Control/README.md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Raspberry_Pi_Power_Control
|
||||
|
||||
Code to accompany this tutorial:
|
||||
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-13-power-control
|
||||
23
Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py
Normal file
23
Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import time
|
||||
import board
|
||||
from digitalio import DigitalInOut, Direction
|
||||
|
||||
pir_pin = board.D24
|
||||
power_pin = board.D23
|
||||
|
||||
pir = DigitalInOut(pir_pin)
|
||||
pir.direction = Direction.INPUT
|
||||
|
||||
power = DigitalInOut(power_pin)
|
||||
power.direction = Direction.OUTPUT
|
||||
power.value = False
|
||||
|
||||
while True:
|
||||
if pir.value:
|
||||
print("POWER ON")
|
||||
power.value = True
|
||||
time.sleep(20)
|
||||
print("POWER OFF")
|
||||
power.value = False
|
||||
time.sleep(5)
|
||||
time.sleep(1)
|
||||
Loading…
Reference in a new issue