From 3da02659e684a02111dc86757f804c13bbd88724 Mon Sep 17 00:00:00 2001 From: ckd2-elford <cosmo2.elford@live.uwe.ac.uk> Date: Tue, 7 Nov 2023 19:19:08 +0000 Subject: [PATCH] Update 2 files - /README.md - /buttonTest.py --- README.md | 4 ++-- buttonTest.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 buttonTest.py diff --git a/README.md b/README.md index eae0b3e..408e305 100644 --- a/README.md +++ b/README.md @@ -90,12 +90,12 @@ I added 3 blue LEDs, to test they worked correctly I turned them all on using ba <br> -**Testing and implementing the code below it follows the spec you have provided. I've added a short video showcasing it in action!** - **Short demo:** [](http://www.youtube.com/watch?v=K9MPf20hbis) +**Testing and implementing the code below it follows the spec you have provided. I've added a short video showcasing it in action!** + *Final code:* ``` import RPi.GPIO as GPIO diff --git a/buttonTest.py b/buttonTest.py new file mode 100644 index 0000000..ae5ef0d --- /dev/null +++ b/buttonTest.py @@ -0,0 +1,15 @@ +import RPi.GPIO as GPIO +import time + +GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) + +GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP) + +while True: + inputValue = GPIO.input(15) + if (inputValue == False): + print("Button pressed") + + # Sleep here to prevent button from beind held down + time.sleep(0.25) \ No newline at end of file -- GitLab