-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton_count_led.py
More file actions
55 lines (49 loc) · 1.32 KB
/
button_count_led.py
File metadata and controls
55 lines (49 loc) · 1.32 KB
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
print("Hello world!")
from adafruit_circuitplayground import cp
import time
import rainbowio
from audiopwmio import PWMAudioOut as AudioOut
import audiocore
import math
import board
import digitalio
# KNOWN ISSUES
# - nothing to prevent you from messing with dial mid-rotation (you get mod 10)
brown = digitalio.DigitalInOut(board.A3)
orange = digitalio.DigitalInOut(board.A2)
def beep_times(num):
print("I beep this many times:")
print(num)
cp.pixels.fill((0,0,0))
cp.pixels[num % 10] = (0,30,5)
button_state = False
counter = 0
while True:
dialling = brown.value
if not dialling:
if counter > 0:
print("Finished with non-zero value for counter")
print(counter)
beep_times(counter)
counter = 0
else:
if orange.value:
cp.red_led = True
if button_state:
# Was on, stay on
pass
else:
# Was off, now on
print("Yes on!")
button_state = True
else:
cp.red_led = False
if button_state:
# Was on, now off
print("Now off!")
counter += 1
pass
else:
# Was off, stay off
pass
button_state = False