6

I'm a bit of a noob in the Arduino area but I found an Arduino nano I bought a long time ago sitting on my shelf and collecting dust, so I taught "why not make a project". I game a lot of racing games so I wanted to make a simple ignition button with it, but every time I tried to compile or verify it, it says

Keyboard not found. Does your sketch include the line #include "Keyboard.h"

Greenonline
  • 2,938
  • 7
  • 32
  • 48
brandon bondig
  • 61
  • 1
  • 1
  • 2
  • 1
    did you include the keyboard library from the Sketch menu? – dandavis Jun 17 '17 at 19:12
  • 3
    @dandavis - that would not be possible or at least not meaningful, as there is no such library for a nano. – Chris Stratton Jun 17 '17 at 21:39
  • @ChrisStratton: good call. – dandavis Jun 17 '17 at 23:27
  • Unlike and official Arduino Uno, which uses a re-programmable ATmega16U2 for an USB to UART interface, a Nano uses an non re-porgrammable FTDI chip. – gre_gor Jun 19 '17 at 13:44
  • A typical Nano has no hardware support for this - so you could only do it by a means such as software-approximate USB, or by adding a USB device interface chip. As the answer suggests, there are better platform choices. – Chris Stratton Mar 14 '18 at 17:01
  • Maybe this question might help you. https://arduino.stackexchange.com/questions/76557/how-can-i-make-my-arduino-uno-press-space-on-my-laptop-keyboard/76570#76570 – Dorian Mar 03 '21 at 17:36
  • Arduino Nano I am not sure. But I am sure that you can do it with Arduino UNO. https://www.youtube.com/watch?v=tvqA-JcTQNg – Yiming Mar 13 '22 at 14:08

2 Answers2

14

Get yourself a Arduino Leonardo, Micro or Pro Micro (or Due, Zero, M0). Those can emulate a keyboard.
Start with reading the Arduino Keyboard Mouse reference.

The Arduino Nano can not use the Arduino Keyboard Mouse library.

Since many years, there is a library called "V-USB" that requires some extra hardware and makes it possible for a ATmega328p microcontroller to act as an USB device. It is not something for a beginner.

A few years ago, Arduino has changed the way the USB is used. The NicoHood HID library makes use of the new possibilities. It makes it possible for example to have extended features for a USB keyboard, like the media keys.

For a normal keyboard and mouse, the Arduino Keyboard Mouse library will do. It will be perfect for a ignition button. But you have to buy one of those boards (Leonardo, and so on).

Jot
  • 3,246
  • 1
  • 13
  • 21
3

The solution to get a board that has built in USB support is not preferred for someone who just wants to use the boards they already have. It is possible to use a board that can communicate with your computer over serial, such as the Arduino Nano, to send data to a Python program which can then turn the input from the Arduino into keyboard presses, etc. using libraries.

For this approach, you would need to know python. The libraries to use are:

pyserial - communication with Arduino

pynput - control the computer's keyboard

threading (comes with python) - allow pyserial and pynput to work simultaneously

nicholas
  • 131
  • 1