c++ – Keyboard not found even though Im including Keyboard.h

c++ – Keyboard not found even though Im including Keyboard.h

Arduino/Genuino Uno does not support Keyboard. You can see it in hardware/ardunino/avr/libraries/HID/HID.h. This file is included from Keyboard.h and contains #if defined(USBCON). But USBCON is not defined for Arduino/Genuino Uno. You need to use another board for Keyboard.h

Following controllers support it:

  • ATmega32U6
  • ATmega8U2
  • ATmega16U2
  • ATmega16U4
  • ATmega32U2
  • ATmega32U4
  • and some ATxxUSBxx

Arduino/Genuino Uno uses ATmega32U8.

You know what you dont require the 32u4 now, I got a solution to use keyboard and mouse through any Arduino.

All you have to do is something like this:

Serial.println(pressA)

On the Arduino

Head to a python script and do this:

import serial
import pyautogui
Arduino_Serial = serial.Serial(COM5, 9600)

while 1:
    incoming_data = str(Arduino_Serial.readline())
    print(incoming_data)
    if pressA in incoming_data:
        pyautogui.press(a)
    incoming_data = 

c++ – Keyboard not found even though Im including Keyboard.h

Leave a Reply

Your email address will not be published. Required fields are marked *