USBKeyboard "Hello world" example (LEDs setting removed as we don't have LEDs)

Dependencies:   mbed USBDevice

main.cpp

Committer:
cspista
Date:
2022-06-16
Revision:
0:060ef37bda98

File content as of revision 0:060ef37bda98:


/* 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);
    }
}