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 0:89906fbcaff9, committed 2015-04-19
- Comitter:
- dannellyz
- Date:
- Sun Apr 19 19:37:35 2015 +0000
- Commit message:
- Code to receive the full appborad data
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Apr 19 19:37:35 2015 +0000
@@ -0,0 +1,33 @@
+// Example of parsing the serial string from the fullAppBaordSend
+/* Code derived from the work of Joe Bradshaw:
+ http://developer.mbed.org/users/jebradshaw/ */
+/******************Declaration of necessary libraries and objects************************/
+#include "mbed.h"
+DigitalOut myled(LED1); //LED to show functionality
+Serial pc(USBTX, USBRX); //tx, rx via USB connection
+Serial xbee(p9, p10); //tx, rx via Xbee socket
+int main() {
+/******************Establishment of Vaiables*********************************************/
+ char abstr[25]; //used to store the whole app board string
+ int joystick; //int value corresponding to the joystick bus
+ float Lpot; //float corresponding to left potentiometer
+ float Rpot; //float corresponding to right potentiometer
+/******************While loop call to run code indefinitely******************************/
+ while(1) {
+ //clear out the remaining characters in the buffer
+ while(xbee.readable())
+ char c = xbee.getc();
+ //read the serial string from the xbee (starts with '$', ends with \r\n
+ xbee.scanf("$%s\r\n", &abstr);
+ //Verify that the string has the APPBOARD header
+ if(strncmp(abstr, "APPBOARD", 9)){
+ //Verify the tring was able to be parsed
+ if (sscanf(abstr, "APPBOARD,%f,%f,%d",&Lpot,&Rpot,&joystick) >= 1) {
+ //Print values to screen
+ pc.printf("Mbed: L-%.02f: R-%.02f Joystick:%d\r\n",Lpot,Rpot,joystick);}
+ //Incorrect parse
+ else{pc.printf("BAD parse %s\r\n", abstr);}
+ }//if(sscanf
+ myled = !myled; //toggle LED for activity verification
+ }//while(1)
+}//main
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Apr 19 19:37:35 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file