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.
Dependencies: mbed
Fork of frdm_Grove_Joystick_Example by
Revision 0:2f9598399d00, committed 2016-01-01
- Comitter:
- GregC
- Date:
- Fri Jan 01 16:56:40 2016 +0000
- Commit message:
- Freedom Seeed Grove Joystick Example
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 Fri Jan 01 16:56:40 2016 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+
+AnalogIn xAxis(A0);
+AnalogIn yAxis(A1);
+
+int x,y,button; // global variables to hold values
+Ticker joystick; // recurring interrupt to get joystick data
+
+void joystick_Int_Handler()
+{
+ x = xAxis.read() * 1000; // float (0->1) to int (0-1000)
+ y = yAxis.read() * 1000;
+ if ( (x > 900) || (y > 900) )
+ button = 1;
+ else
+ button = 0;
+}
+
+int main()
+{
+ // init interrupt, call every .2s
+ joystick.attach(joystick_Int_Handler,0.2);
+
+ // Print out the variables
+ while(1){
+ printf("\rX=%3d, Y=%3d, Button=%d",x,y,button);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 01 16:56:40 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file
