-
Notifications
You must be signed in to change notification settings - Fork 25
Using the Library
For a documentation of the complete library API please use the source documentataion. This page discribes some features of the MyoBridge Library in detail.
Establishing a connection to the Myo Armband via the Bluetooth module is a critical step for any application using the library. If you need more information about what is currently going on or where a problem might occur,
you can set a callback function that provides information about the current state during connection. Supply this function as parameter to begin()
:
//a function to inform us about the current state
// and the progess of the connection to the Myo.
void printConnectionStatus(MyoConnectionStatus status) {
//print the status constant as string
Serial.println(bridge.connectionStatusToString(status));
}
.
.
.
//initiate the connection with the status callback function
bridge.begin(printConnectionStatus);
This will print the current state to the hardware serial connection, which is especially useful for debug purposes. Keep in mind that this function should have a short execution time, so it does not block the begin()
function too long.
To make sure the your program will connect under any circumstances, you can also supply a reset pin when you create the MyoBridge object:
MyoBridge bridge(mySerial, RESET_PIN);
This pin has to be connected to the reset pin of your bluetooth module. Also keep in mind that the HM-11 operates at 3.3V! To address that, you can use a voltage divider or a regulator chip. A setup using software serial could look like this:
If the Bluetooth module does not respond any more or hangs in an unusable state, the library will now reset it by pulling the reset pin low for a short time.