-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpioTest.py
More file actions
33 lines (23 loc) · 835 Bytes
/
gpioTest.py
File metadata and controls
33 lines (23 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import RPi.GPIO as GPIO
import time
# Configure pin and pull-down resistor.
GPIO.setmode(GPIO.BCM)
input_pin = 17
GPIO.setup(input_pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
output_pin = 27
GPIO.setup(output_pin, GPIO.OUT)
try:
while True:
if GPIO.input(input_pin) == GPIO.HIGH:
print("The red button has been pushed! What is wrong with you?!")
GPIO.output(output_pin, GPIO.HIGH)
# I will need to experiment to see how long it takes for the sphere to spin.
time.sleep(1)
GPIO.output(output_pin, GPIO.LOW)
else:
print(time.strftime("%H:%M:%S", time.localtime() ) )
time.sleep(0.5)
except KeyboardInterrupt:
print("Exiting program... I hope you're happy.")
finally:
GPIO.cleanup()