Simple example on how to use the application board joystick as input for your pc.

Dependencies:   USBDevice mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Revision:
7:6081df4a2680
Parent:
5:03a4211d593a
--- a/main.cpp	Fri Mar 01 13:23:58 2013 +0000
+++ b/main.cpp	Sat Feb 20 12:03:19 2016 +0000
@@ -1,21 +1,33 @@
 #include "mbed.h"
 #include "USBKeyboard.h"
- 
-//LED1: NUM_LOCK
-//LED2: CAPS_LOCK
-//LED3: SCROLL_LOCK
-BusOut leds(LED1, LED2, LED3);
- 
+
+
+BusOut leds(LED1, LED2, LED3);                  //Not used
+DigitalIn rechts(p16);                          //Joystick pins on application board
+DigitalIn up(p15);
+DigitalIn down(p12);
+DigitalIn left(p13);
+
 //USBKeyboard
-USBKeyboard keyboard;
- 
-int main(void) {
+USBKeyboard keyboard;                           // create keyboard object
+
+int main(void)
+{
     while (1) {
-        keyboard.mediaControl(KEY_VOLUME_DOWN);
-        keyboard.printf("Hello World from Mbed\r\n");
-        keyboard.keyCode('s', KEY_CTRL);
-        keyboard.keyCode(KEY_CAPS_LOCK);
-        wait(1);
-        leds = keyboard.lockStatus();
+                                                //all pins are checked whtether or not they are pressed
+        if(rechts) {
+            keyboard.keyCode(RIGHT_ARROW);      //send the appropriate key
+        }
+        if(up) {
+            keyboard.keyCode(UP_ARROW);
+        }
+        if(down) {
+            keyboard.keyCode(DOWN_ARROW);
+        }
+        if(left) {
+            keyboard.keyCode(LEFT_ARROW);
+        }
+        
+        leds = keyboard.lockStatus();           //not used
     }
 }
\ No newline at end of file