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 1:cb4a1b11de74, committed 2016-02-24
- Comitter:
- co838_gtvl2
- Date:
- Wed Feb 24 20:40:54 2016 +0000
- Parent:
- 0:9c531a8dcb06
- Commit message:
- Added 5 way Joystick support. (configured for horizontal use)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9c531a8dcb06 -r cb4a1b11de74 main.cpp --- a/main.cpp Wed Feb 24 19:55:15 2016 +0000 +++ b/main.cpp Wed Feb 24 20:40:54 2016 +0000 @@ -1,18 +1,25 @@ #include "mbed.h" #include "FXOS8700Q.h" +// Serial link to the pc Serial pc(USBTX, USBRX); +// Accelerometer FXOS8700Q_acc accel(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); +// Joystick +DigitalIn up(A2); +DigitalIn down(A3); +DigitalIn left(A4); +DigitalIn right(A5); +DigitalIn fire(D4); void pc_interrupt(void) { pc.getc(); - wait(.01); int16_t accX, accY, accZ; accel.getX(&accX); accel.getY(&accY); accel.getZ(&accZ); - pc.printf("%d;%d;%d\r\n", accX, accY, accZ); + pc.printf("%d;%d;%d;%d;%d;%d;%d;%d;\r\n", accX, accY, accZ, right ? 1 : 0, down ? 1 : 0, left ? 1 : 0, up ? 1 : 0, fire ? 1 : 0); } int main(void) @@ -21,6 +28,7 @@ pc.attach(&pc_interrupt); accel.enable(); + wait(.01); while (true) { sleep(); }