From 4918589b55db2e0671f034978baaae24eb8eb48e Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Sun, 21 Mar 2021 18:12:26 -0400 Subject: [PATCH] wip --- GPIO/RPi.GPIO/ring.RPi.GPIO.py | 24 ++++++++++++++++++++++++ GPIO/gpiozero/ring.gpiozero.py | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 GPIO/RPi.GPIO/ring.RPi.GPIO.py create mode 100644 GPIO/gpiozero/ring.gpiozero.py diff --git a/GPIO/RPi.GPIO/ring.RPi.GPIO.py b/GPIO/RPi.GPIO/ring.RPi.GPIO.py new file mode 100644 index 0000000..e4199e9 --- /dev/null +++ b/GPIO/RPi.GPIO/ring.RPi.GPIO.py @@ -0,0 +1,24 @@ +# +# ring.RPi.GPIO.py +# Raspberry Pi RPI.GPIO ring oscillator test +# +# Neil Gershenfeld 3/21/21 +# +# This work may be reproduced, modified, distributed, +# performed, and displayed for any purpose, but must +# acknowledge this project. Copyright is retained and +# must be preserved. The work is provided as is; no +# warranty is provided, and users accept all liability. +# +import RPi.GPIO as GPIO +pinout = 16 +pinin = 18 +GPIO.setwarnings(False) +GPIO.setmode(GPIO.BOARD) +GPIO.setup(pinout,GPIO.OUT) +GPIO.setup(pinin,GPIO.IN) +while (True): + if (GPIO.input(pinin) == GPIO.LOW): + GPIO.output(pinout,GPIO.HIGH) + else: + GPIO.output(pinout,GPIO.LOW) diff --git a/GPIO/gpiozero/ring.gpiozero.py b/GPIO/gpiozero/ring.gpiozero.py new file mode 100644 index 0000000..30316c1 --- /dev/null +++ b/GPIO/gpiozero/ring.gpiozero.py @@ -0,0 +1,21 @@ +# +# ring.gpiozero.py +# Raspberry Pi gpiozero ring oscillator test +# +# Neil Gershenfeld 3/21/21 +# +# This work may be reproduced, modified, distributed, +# performed, and displayed for any purpose, but must +# acknowledge this project. Copyright is retained and +# must be preserved. The work is provided as is; no +# warranty is provided, and users accept all liability. +# +from gpiozero import LED +from gpiozero import Button +led = LED(23) +button = Button(24) +while (True): + if button.is_pressed: + led.on() + else: + led.off() -- GitLab