-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathalks.py
More file actions
170 lines (142 loc) 路 2.2 KB
/
Copy pathalks.py
File metadata and controls
170 lines (142 loc) 路 2.2 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import machine
import network
import time
# Pinout definition
TX = 1
RX = 3
D0 = 40
D1 = 41
D2 = 15
D3 = 2
D4 = 0
D5 = 4
D6 = 16
D7 = 17
D8 = 5
D9 = 18
D10 = 19
D11 = 21
D12 = 22
D13 = 23
A0 = 32
A1 = 33
A2 = 25
A3 = 26
A4 = 27
A5 = 14
A6 = 12
A7 = 15
L_R = 22
L_G = 17
L_Y = 23
L_B = 5
L_RGB_R = 4
L_RGB_G = 21
L_RGB_B = 16
SW1 = 15
SW2 = 2
SW3 = 0
POT1 = 32
POT2 = 33
PIEZO1 = 19
PIEZO2 = 18
PHOTO = 25
DHT_PIN = 26
S1 = 4
S2 = 16
S3 = 18
S4 = 19
S5 = 21
SDA = 27
SCL = 14
SS = 19
MOSI = 21
MISO = 22
SCK = 23
DAC1 = 25
DAC2 = 26
r = None
g = None
b = None
y = None
def setupLeds():
global r, g, b, y
r = machine.Pin(L_R, machine.Pin.OUT)
g = machine.Pin(L_G, machine.Pin.OUT)
b = machine.Pin(L_B, machine.Pin.OUT)
y = machine.Pin(L_Y, machine.Pin.OUT)
RGBr = None
RGBg = None
RGBb = None
def setupRgbLeds():
global RGBr, RGBg, RGBb
RGBr = machine.Pin(L_RGB_R, machine.Pin.OUT)
RGBg = machine.Pin(L_RGB_G, machine.Pin.OUT)
RGBb = machine.Pin(L_RGB_B, machine.Pin.OUT)
sw1 = None
sw2 = None
sw3 = None
def setupButtons():
global sw1, sw2, sw3
sw1 = machine.Pin(SW1, machine.Pin.IN, machine.Pin.PULL_UP)
sw2 = machine.Pin(SW2, machine.Pin.IN, machine.Pin.PULL_UP)
sw3 = machine.Pin(SW3, machine.Pin.IN, machine.Pin.PULL_UP)
piezo = None
def setupPiezo():
global piezo
piezo = machine.PWM(machine.Pin(PIEZO1))
piezoGND = machine.Pin(PIEZO2, machine.Pin.OUT)
piezoGND.off()
def setupAll()
setupLeds()
setupRgbLeds()
setupButtons()
setupPiezo()
def setupRgbPwm():
global RGBr, RGBg, RGBb
RGBr = machine.PWM(machine.Pin(L_RGB_R))
RGBg = machine.PWM(machine.Pin(L_RGB_G))
RGBb = machine.PWM(machine.Pin(L_RGB_B))
pot1 = None
pot2 = None
def setupPotenciometers():
global pot1, pot2
pot1 = machine.ADC(machine.Pin(POT1))
pot2 = machine.ADC(machine.Pin(POT2))
def delay(ms):
time.delay_ms(ms)
def cekej(ms):
delay(ms)
def testLEDs(t = 100):
global r, g, b, y
global RGBr, RGBg, RGBb
setupLeds()
setupRgbLeds()
r.on()
delay(t)
g.on()
delay(t)
b.on()
delay(t)
y.on()
delay(t)
RGBr.on()
delay(t)
RGBg.on()
delay(t)
RGBb.on()
delay(t)
r.off()
delay(t)
g.off()
delay(t)
b.off()
delay(t)
y.off()
delay(t)
RGBr.off()
delay(t)
RGBg.off()
delay(t)
RGBb.off()
delay(t)