-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (30 loc) · 1001 Bytes
/
main.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
right = 0
left = 0
buggyon = 0
BitBuggy.init_wheel(AnalogPin.P1, AnalogPin.P2)
strip = neopixel.create(DigitalPin.P0, 2, NeoPixelMode.RGB)
def on_button_pressed_a():
global buggyon
buggyon = 1
def on_button_pressed_b():
global buggyon
buggyon = 0
def on_forever():
global left, right, buggyon
input.on_button_pressed(Button.A, on_button_pressed_a)
input.on_button_pressed(Button.B, on_button_pressed_b)
if(buggyon):
left = randint(-100, 100)
right = randint(-100, 100)
BitBuggy.freestyle(left, right)
basic.show_icon(IconNames.SILLY)
for i in range(3):
strip.show_color(neopixel.colors(NeoPixelColors.RED))
basic.pause(150)
strip.show_color(neopixel.colors(NeoPixelColors.BLUE))
basic.pause(150)
else:
strip.show_color(neopixel.colors(NeoPixelColors.GREEN))
BitBuggy.brake()
basic.show_icon(IconNames.HEART)
basic.forever(on_forever)