Reading values from joystick analog pad (Keyes_SJoys)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jose_23991
Date:
Fri Sep 19 13:35:08 2014 +0000
Commit message:
Revision 1.0

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 Sep 19 13:35:08 2014 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+#define T_MS 500                                 // Define the time between reads
+#define VRx A0                                   // Define the input pin for VRx pin
+#define VRy A1                                   // Define the input pin for VRy pin
+#define SW D2                                    // Define the input pin for SW pin
+
+int main()
+{
+    AnalogIn x_axis(VRx);                       // Create the analog x movement object
+    AnalogIn y_axis(VRy);                       // Create the analog y movement object
+    DigitalIn button(SW, PullUp);               // Create the digital button object and setup internall pull-up resistor
+
+    while(1)
+    {   
+        printf("\n");
+        printf("\n X axis: %f", x_axis.read()); // Show the value of the X axis (0.0 to 1.0)
+        printf("\n Y axis: %f", y_axis.read()); // Show the value of the Y axis (0.0 to 1.0)
+        printf("\n Button: %d", button.read()); // Show the button status (0 is pressed, 1 is not pressed)
+        
+        wait_ms(T_MS);                          // Wait time between reads
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 19 13:35:08 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file