breadboard
documentación

Proyecto de ejemplo · Montajes y proyectos

Uno R4 · Teclado y ratón USB

Las bibliotecas oficiales Keyboard y Mouse envían Ctrl+Shift+A, B mayúscula, botones de ratón y movimiento relativo por el controlador USB emulado. Selecciona la placa para ver consola USB e informes HID en el Inspector. Serial repite cada línea que envías. Los informes permanecen en Breadboard.

El circuito Uno R4 · Teclado y ratón USB tal como lo dibuja el simulador

Componentes del montaje

  • Arduino Uno R4

El código

Este sketch de Arduino C++ está en Code; inicia sesión y pulsa Compile & upload para compilar firmware real para la placa emulada.

// SPDX-License-Identifier: MIT
// Official Keyboard 1.0.7 and Mouse 1.0.1 APIs; reports remain in the simulator.
#include <Keyboard.h>
#include <Mouse.h>

void setup() {
  Serial.begin(115200);
  Keyboard.begin();
  Mouse.begin();
  while (!Serial) {}
  Serial.println("public HID ready");
}

void loop() {
  while (Serial.available()) Serial.write(Serial.read());
  Keyboard.press(KEY_LEFT_CTRL);
  Keyboard.press(KEY_LEFT_SHIFT);
  Keyboard.press('a');
  Keyboard.release('a');
  Keyboard.releaseAll();
  Keyboard.write('B');
  Mouse.press(MOUSE_LEFT | MOUSE_RIGHT);
  Mouse.move(7, -3, 1);
  Mouse.release(MOUSE_ALL);
  Mouse.click(MOUSE_MIDDLE);
  Serial.println("public HID reports sent");
  delay(250);
}

Licencia del firmware (en inglés)

Notice: this firmware uses the LGPL-licensed Arduino core library

arduino-unor4wifi-usb-keyboard-mouse.bin is statically linked with ArduinoCore-renesas 1.6.0, in Breadboard's port of its UNO R4 WiFi variant to Renesas FSP 5.3.0. Parts of that core are licensed under the GNU Lesser General Public License, version 2.1 or (at your option) any later version ("the Library"). Breadboard distributes this firmware under terms that permit you to modify the work for your own use and to reverse engineer it for debugging such modifications.

This image also links official Keyboard 1.0.7 and Mouse 1.0.1. Keyboard layout files use the GNU Lesser General Public License, version 3. The package and source bundle include the LGPL-3.0 and GPL-3.0 texts.

Informar de un problema de traducción

Proyectos relacionados