The first time I work with arduino.

The bottom line is that when you press a button, the text is printed

#include <Keyboard.h> #include <Mouse.h> void setup() { pinMode(1,INPUT_PULLUP); Keyboard.begin(); } void loop() { // read the pushbutton: int buttonState = digitalRead(buttonPin); // if the button state has changed, if ((buttonState != previousButtonState) // and it's currently pressed: && (buttonState == HIGH)) { // increment the button counter counter++; // type out a message Keyboard.print("You pressed the button "); } // save the current button state for comparison next time: previousButtonState = buttonState; } 

when compiling produces an error Клавиатура не найдена. Убедитесь входит ли скетч в код #include <Keyboard.h> Клавиатура не найдена. Убедитесь входит ли скетч в код #include <Keyboard.h>

Indicates the string Keyboard.print("You pressed the button ");

  • I usually debug in another way using Serial. - Unick
  • The code will work on Arduion Leonardo and similar boards (which can pretend to be a USB HID device). If you have an Arduino Uno, for example, it will not work. - insolor

1 answer 1

Most likely, the board type is incorrect. This code will only work on an ATmega32u4 processor.

  • The fact is that my computer doesn’t see this device at all, the LEDs blink, but that’s all . KTA