Bluetooth
(If you cannot use Bluetooth, try TV Remote)
Why use Bluetooth? - well, it's a way to send messages to your robot without using a PC.
You can use your phone to set different values in your program - speed, for example,
and, because there are no wires, you can change speed settings as it is running.
It's most useful in line following and Drag racing, but can be used in wall following.
The Bluetooth App
Here's a link to a goodBluetooth App that works on Android.
How do you configure the app to have the right buttons?
You can set the buttons manually, by long clicking on each button, and setting
- its name,
- the data that it sends,and
- whether it sends immediately,
Or you can import configuration from a file:
You need to go to the configuration screen on the app, and Import the above file you have downloaded.
How do you set up your robot for Bluetooth?
There is a Bluetooth module that plugs in (4 pins) to the base of the UKMARS bot.
It's called the HC06, and
it looks like this:
Is there a Python module for Bluetooth?
There's one just developed that lets you control the speed, the steering strength, and the derivative
with simple single button presses on your phone.(see below).
It's called "Bluetooth.py" link
Your program needs the following at the start
from Bluetooth import *
import params as p # imports basespeed, efactor, dfactor
BT = Bluetooth(1)
Then, inside your loops, to allow commands, include the following
if (BT.Ready()):
BT.Cmd()
and use:
p.basespeed for speed,
p.efactor for steering strength,
and p.dfactor for derivative.
What are the commands?
Commands (no 'enter' needed - single keystroke)
These select which variable to change:
s (speed)
e (efactor)
d (dfactor)
(they also print out its current value)
These modify the selected variable:
0 (Zero) sets selected variable to zero
+ increases the selected variable
- decreases the selected variable (but not below zero)
1 sets the increase/decrease amount to 1
5 sets the increase/decrease amount to 5
Storage of variables:
w (Save) saves the variables to file params.py so they will survive power-down
r (Reload) re-reads variables from file params.py - Go back to last saved set.
? (Help) gives this list of commands,
q (Display) prints out all variable values.