István Cserny
/
Lab10_USB_keyboard
USBKeyboard "Hello world" example (LEDs setting removed as we don't have LEDs)
Diff: main.cpp
- Revision:
- 0:060ef37bda98
diff -r 000000000000 -r 060ef37bda98 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 16 12:55:34 2022 +0000 @@ -0,0 +1,26 @@ + +/* USBKeyboard example + * This program will emulate a keyboard and emits few keycodes + * each time when the B1 user button was pressed. + * + * Tested on NUCLEO-F446RE board with Mbed 2 + */ +#include "mbed.h" +#include "USBKeyboard.h" + +DigitalIn SW1(BUTTON1,PullUp); +USBKeyboard keyboard; + +int main(void) +{ + while (1) { + while(SW1==1) {} + keyboard.mediaControl(KEY_VOLUME_DOWN); + keyboard.printf("Hello World from Mbed USBKeyboard demo\r\n"); + keyboard.keyCode('s', KEY_CTRL); + keyboard.keyCode(KEY_CAPS_LOCK); + wait(0.02); + while(SW1==0) {} + wait(0.02); + } +} \ No newline at end of file