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

main.cpp

Committer:
Perijah
Date:
2016-02-20
Revision:
7:6081df4a2680
Parent:
5:03a4211d593a

File content as of revision 7:6081df4a2680:

#include "mbed.h"
#include "USBKeyboard.h"


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;                           // create keyboard object

int main(void)
{
    while (1) {
                                                //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
    }
}