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

Committer:
Perijah
Date:
Sat Feb 20 12:03:19 2016 +0000
Revision:
7:6081df4a2680
Parent:
5:03a4211d593a
Keyboard with mbed application board joystick functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 1:291a88a2c151 1 #include "mbed.h"
samux 1:291a88a2c151 2 #include "USBKeyboard.h"
Perijah 7:6081df4a2680 3
Perijah 7:6081df4a2680 4
Perijah 7:6081df4a2680 5 BusOut leds(LED1, LED2, LED3); //Not used
Perijah 7:6081df4a2680 6 DigitalIn rechts(p16); //Joystick pins on application board
Perijah 7:6081df4a2680 7 DigitalIn up(p15);
Perijah 7:6081df4a2680 8 DigitalIn down(p12);
Perijah 7:6081df4a2680 9 DigitalIn left(p13);
Perijah 7:6081df4a2680 10
samux 3:8b56768ceca2 11 //USBKeyboard
Perijah 7:6081df4a2680 12 USBKeyboard keyboard; // create keyboard object
Perijah 7:6081df4a2680 13
Perijah 7:6081df4a2680 14 int main(void)
Perijah 7:6081df4a2680 15 {
samux 1:291a88a2c151 16 while (1) {
Perijah 7:6081df4a2680 17 //all pins are checked whtether or not they are pressed
Perijah 7:6081df4a2680 18 if(rechts) {
Perijah 7:6081df4a2680 19 keyboard.keyCode(RIGHT_ARROW); //send the appropriate key
Perijah 7:6081df4a2680 20 }
Perijah 7:6081df4a2680 21 if(up) {
Perijah 7:6081df4a2680 22 keyboard.keyCode(UP_ARROW);
Perijah 7:6081df4a2680 23 }
Perijah 7:6081df4a2680 24 if(down) {
Perijah 7:6081df4a2680 25 keyboard.keyCode(DOWN_ARROW);
Perijah 7:6081df4a2680 26 }
Perijah 7:6081df4a2680 27 if(left) {
Perijah 7:6081df4a2680 28 keyboard.keyCode(LEFT_ARROW);
Perijah 7:6081df4a2680 29 }
Perijah 7:6081df4a2680 30
Perijah 7:6081df4a2680 31 leds = keyboard.lockStatus(); //not used
samux 1:291a88a2c151 32 }
samux 4:f0df6aae7147 33 }