Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 5:714f1a772584, committed 2016-03-22
- Comitter:
- tknara
- Date:
- Tue Mar 22 02:21:14 2016 +0000
- Parent:
- 4:3408903ad725
- Child:
- 6:1c68c8eb8082
- Commit message:
- support xbee;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Mar 14 15:48:00 2016 +0000
+++ b/main.cpp Tue Mar 22 02:21:14 2016 +0000
@@ -11,6 +11,8 @@
#define xmagm 1.33
#define ymagp 1.38
#define ymagm 1.75
+#define over 0.2
+#define under -0.2
/*header list */
#define turn 0xFF
#define velocity 0xFA
@@ -35,7 +37,7 @@
}else if(1.1<x){
x=((x-1)*-1)*xmagm;
counter +=2;
- }if((0.1>x)&&(-0.1<x)){
+ }if((over>x)&&(under<x)){
x = 0;
}
if(1.1>y){
@@ -44,7 +46,7 @@
}else if(1.1<y){
y=((y-1)*-1)*ymagm;
counter +=8;
- }if((0.1>y)&&(-0.1<y)){
+ }if((over>y)&&(under<y)){
y = 0;
}
*p = x*x+y*y;
@@ -79,16 +81,19 @@
}
int main() {
- uint8_t deg,dire2;
+ uint8_t deg,dire2,right,left;
float dire1;
Xbee.baud(9600);
while(1) {
+ right = RT*255;
+ left = LT*255;
deg = getdeg(&dire1);
dire2=255*dire1;
Xbee.putc(255);
Xbee.putc(deg);
- Xbee.putc(dire2);
- printf("%d,%d\n",deg,dire2);
+ Xbee.putc(right);
+ Xbee.putc(left);
+ printf("%d,%d,%d,%d\n",deg,dire2,right,left);
wait(0.1);
}
}