From e874794564d3b604b94945f7c807fa3992e4016e Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Tue, 2 Apr 2019 18:25:14 -0600 Subject: [PATCH] code runs well using CircuitPython, linted --- .../.Raspberry_Pi_Power_Control.py.swp | Bin 0 -> 12288 bytes Raspberry_Pi_Power_Control/.eg.py.swp | Bin 0 -> 12288 bytes Raspberry_Pi_Power_Control/README.md | 4 +++ .../Raspberry_Pi_Power_Control.py | 23 ++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 Raspberry_Pi_Power_Control/.Raspberry_Pi_Power_Control.py.swp create mode 100644 Raspberry_Pi_Power_Control/.eg.py.swp create mode 100644 Raspberry_Pi_Power_Control/README.md create mode 100644 Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py diff --git a/Raspberry_Pi_Power_Control/.Raspberry_Pi_Power_Control.py.swp b/Raspberry_Pi_Power_Control/.Raspberry_Pi_Power_Control.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..f536c03caa6d515993a8215af848aa1be7ff6fbd GIT binary patch literal 12288 zcmeI2F>ljA6o6kDSWpTo1M3l%R6@3!PzhCHs2YMIL1Rin7bNR~FXc&&eVpw^S@;L^ zPXH@3Oz=DS14xJsgkV7M&UJ9A7Rtgx-br7ayu0`A-8VWn^zL`>i0h6AG%f&~{r>F1 z%X7={VI4rD4W2$U?ze`gFM}r<-F7mGqeOL27WS8CfG{i%p}ntrW`%}i)MHU8(264HE1>0yesv~;^N9+;ZDy7 zW&>=14X^<=zy{a=8(;&AZXnZ3@Pj0rAubV1CG_CI2G{@_U;}J`4X^<=zy{a=8(;%$ zfDQa724o2ErUu|H(}C#!fBO#L^Lc>x#B1Ue@timyo)V9VyM#}8M2+}HxnGHo#5>|G z@q#!YQev0bBGvqq5@XpC3wrFr9=T%o&N6hLz<9nCDcxZ+NQXvr{LvgH literal 0 HcmV?d00001 diff --git a/Raspberry_Pi_Power_Control/.eg.py.swp b/Raspberry_Pi_Power_Control/.eg.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..bcbb4325f5ba84d729e473f3dbbbca0dd58d3643 GIT binary patch literal 12288 zcmeI2&ubGw6vtn^id9rRkMWX)vb#-Gq*73;DG}Q&u|F=tvSFunV6!{S%o=j>=+%F~ zn1uMQ)U*9Q_~gf%d2ePu$K4sld;KkOCya^X649q0Z=ZcQ zzfAXT6KUm>r-xQAx}(#l(MzqOht;Gksw}rrmS@rZJUcM8a_JM9nNpR9>C>roa-43~ zDwj4IW>$}+G1D|rX;Mw3NjIv}nW~87VW_A7uqdX$01Pw+E>O3#8sBJL7gsLt!U_z) z01UtY48Q;kzyJ)uz!@{(^b-B#GoNFwGD{8og@6GVfB_hQ0T_S*7=Qs7fB_hQ0T}pC z3}iXK_FpD)jDP>{p8*_QB>K*LWxg;UnfJ^)<~3uPeP)k&%*4z!=7@WIV?Hx)m{*MN zYZ(L#zyJ)u01UtY48Q;kzyJ)uz}Yh(IGh^G&=yka_G&;r<6|LvYo1kASk+F~uB~TR zz_lt@L@z6>oX^olm9E`N2K$eOV$kcg=0gijJ8^KAW-IZ>iEVdG{nxJBO;dH?YgIYh zkuoXoCs?D&b5%&;>(_`*?A>gc$E|fuWQDR`>yzv`rCov+xWlFF4je- u%a`+K3;RDedGxq&T;;OOKObytafur1$~ZAhRJfV+2O_iF?N8ck5%dem3b82w literal 0 HcmV?d00001 diff --git a/Raspberry_Pi_Power_Control/README.md b/Raspberry_Pi_Power_Control/README.md new file mode 100644 index 000000000..706279875 --- /dev/null +++ b/Raspberry_Pi_Power_Control/README.md @@ -0,0 +1,4 @@ +# Raspberry_Pi_Power_Control + +Code to accompany this tutorial: +https://learn.adafruit.com/adafruits-raspberry-pi-lesson-13-power-control diff --git a/Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py b/Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py new file mode 100644 index 000000000..81725a7c1 --- /dev/null +++ b/Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py @@ -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)