-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchonkyLED.py
56 lines (44 loc) · 1.15 KB
/
chonkyLED.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python3
# This code is for the Spot neighbour for GreatFET.
# This code works when Spot is plugged into GreatFET.
# Load this file into a Python interpretive shell using:
# exec(open("chonkyLED.py").read())
import time
from greatfet import GreatFET
gf = GreatFET()
# Set the pins
greenPin = gf.gpio.get_pin('J1_P23')
redPin = gf.gpio.get_pin('J2_P23')
# Set the direction of the pins
greenPin.set_direction(gf.gpio.DIRECTION_OUT)
redPin.set_direction(gf.gpio.DIRECTION_OUT)
# Turn the red LED on.
def redOn():
redPin.write(True)
# Turn the red LED off.
def redOff():
redPin.write(False)
# Blink the red LED.
def redBlink():
for i in range(10):
redPin.write(not redPin.read())
time.sleep(0.2)
# Turn the green LED on.
def greenOn():
greenPin.write(True)
# Turn the green LED off.
def greenOff():
greenPin.write(False)
# Blink the green LED.
def greenBlink():
for i in range(10):
greenPin.write(not greenPin.read())
time.sleep(0.2)
# Turn both the green and red LED on.
def yellowOn():
redPin.write(True)
greenPin.write(True)
# Turn both the green and red LED off.
def allOff():
redPin.write(False)
greenPin.write(False)