/
readPoseData.ino
executable file
·44 lines (34 loc) · 1.1 KB
/
readPoseData.ino
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
#include <MyoBridge.h>
#include <SoftwareSerial.h>
//SoftwareSerial connection to MyoBridge
SoftwareSerial bridgeSerial(2,3);
//initialize MyoBridge object with software serial connection
MyoBridge bridge(bridgeSerial);
//declare a function to handle pose data
void handlePoseData(MyoPoseData& data) {
//convert pose data to MyoPose
MyoPose pose;
pose = (MyoPose)data.pose;
//print the pose
Serial.println(bridge.poseToString(pose));
}
void setup() {
//initialize both serial connections
Serial.begin(115200);
bridgeSerial.begin(115200);
//wait until MyoBridge has found Myo and is connected. Make sure Myo is not connected to anything else and not in standby!
Serial.println("Searching for Myo...");
bridge.begin();
Serial.println("connected!");
//set the function that handles pose events
bridge.setPoseEventCallBack(handlePoseData);
//tell the Myo we want Pose data
bridge.enablePoseData();
//make sure Myo is unlocked
bridge.unlockMyo();
//You have to perform the sync gesture to receive Pose data!
}
void loop() {
//update the connection to MyoBridge
bridge.update();
}