segway_self balancing robot 4180 project
Dependencies: mbed mbed-rtos LSM9DS1_Library
Diff: main.cpp
- Revision:
- 9:28821420f7a4
- Parent:
- 8:2332c4a79276
- Child:
- 10:aafadd98d91c
- Child:
- 11:c669b4dc1f9f
--- a/main.cpp Sat Apr 18 19:39:10 2020 +0000
+++ b/main.cpp Sat Apr 18 20:03:58 2020 +0000
@@ -16,9 +16,13 @@
void bluetooth_update() {
char bnum=0;
char bhit=0;
- if (blue.getc()=='!') {
+
+ while (blue.getc()!='!') {
+
+ }
if (blue.getc()=='B') { //button data packet
bnum = blue.getc(); //button number
+ pc.printf("%d",bnum);
bhit = blue.getc(); //1=hit, 0=release
if (blue.getc()==char(~('!' + 'B' + bnum + bhit))) { //checksum OK?
myled = bnum - '0'; //current button number will appear on LEDs
@@ -84,14 +88,15 @@
}
}
}
- }
+ //}
}
int main() {
pc.printf("this is running");
- bluetooth.attach(&bluetooth_update, 0.1);
+ //bluetooth.attach(&bluetooth_update, 0.1);
while(1) {
- pc.printf("rp: %f, rd: %f, ri: %f, desired_angle: %f", rp, rd, ri, desired_angle);
+ bluetooth_update();
+ pc.printf("rp: %f, rd: %f, ri: %f, desired_angle: %f\n", rp, rd, ri, desired_angle);
wait(0.1);
}
}
