3 years, 1 month ago.

Can any of the NUCLEO boards be set up as HID Keyboard AND Mouse

Hi all, I want to make a few prototype units for a new project. I have looked in Farnell and the NUCLEO-F042K6 is less than £9 So no real issue with that.

But Ideally I want it to be a USB Keyboard AND Mouse, Or a basic HID,

Can any of theses boards (the long thin form factor ones) do the above ??




My requirements are 6 PWM's 6 ADC's

A couple of buttons & LED's.

Maybe, 10 NEO-PIXEL'S

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F042K6T6 microcontroller.

1 Answer

3 years, 1 month ago.

Hello Ceri,

The NUCLEO-F042K6 board shall be OK. Have a look at Norimasa Okamoto's site https://os.mbed.com/users/va009039/code/F042K6_USBDevice/ for more details. However, you can give also the low cost STM32F103C8T6 or the Maple Mini boards a try. For testing, load the STM32F103C8T6_USBSerial or MapleMini_USBSerial demo into the online compiler and modify the code according to the USBMouseKeyboard demo (see below).

#include "stm32f103c8t6.h"
#include "mbed.h"
//#include "USBSerial.h"
#include "USBMouseKeyboard.h"

int main() {
    confSysClock();         //Configure system clock (72MHz HSE clock, 48MHz USB clock)
    Serial    pc(PA_2, PA_3);
    DigitalOut  myled(LED1);
    //USBSerial usbSerial;    // connection is blocked when USB is not plugged in
    //USBSerial usbSerial(0x1f00, 0x2012, 0x0001,  false);// connection is not blocked when USB is not plugged in
    USBMouseKeyboard key_mouse;
    while (1) {
        //myled = !myled;
        //pc.printf("I am a serial port\r\n");            // 9600 bit/s
        //usbSerial.printf("I am a USB serial port\r\n"); // 12 Mbit/s (USB full-speed)

        key_mouse.printf("Hello World from Mbed\r\n");
        key_mouse.keyCode('s', KEY_CTRL);
        key_mouse.move(20, 0);
        myled = key_mouse.lockStatus();

Remember to select the NUCLEO-F103RB platform as target for the online compiler.

It worked for me fine.

Accepted Answer

Amazing, Thanks for the response, That is almost all of the code I will need, except for the ADC/PWM, and the math behind it.

Do you know if I can have Keyboard & Mouse, And USB Serial at the same time.

That will rely make my project FLY :)

posted by ceri clatworthy 08 May 2018