-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
48 lines (43 loc) · 1.63 KB
/
code.py
File metadata and controls
48 lines (43 loc) · 1.63 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
# Simple code to read a message from the Dabble App over the DSDTech HM-10 bluetooth module
# Author: Eric Z. Ayers <ericzundel@gmail.com>
"""CircuitPython Example of how to read data from the Dabble app"""
import binascii
import board
import busio
import digitalio
import time
from dabble import Dabble
dabble = Dabble(board.GP0, board.GP1, debug=True)
while True:
message = dabble.read_message()
if (message != None):
print("Message: " + str(message))
# Implement tank steering on a 2 wheeled robot
if (message.up_arrow_pressed):
print("Move both motors forward")
elif (message.down_arrow_pressed):
print("Move both motors backward")
elif (message.right_arrow_pressed):
print("Move left motor forward and right motor backward")
elif (message.left_arrow_pressed):
print("Move left motor backward and right motor forward")
elif (message.no_direction_pressed):
print("Stop both motors")
else:
print("Something crazy happened with direction!")
if (message.triangle_pressed):
print("Raise arm")
elif (message.circle_pressed):
print("Lower arm")
elif (message.square_pressed):
print("Squirt water")
elif (message.circle_pressed):
print("Fire laser")
elif (message.start_pressed):
print("Turn on LED")
elif (message.select_pressed):
print("Do victory dance")
elif (message.no_action_pressed):
print("No action")
else:
print("Something crazy happened with action!")