skip to content

Search

Arduino Mega or Uno as a HID Keyboard

2 min read

A step-by-step guide to turning your Arduino Mega or Uno into a HID keyboard using FLIP and custom HEX firmware.

Arduino Mega or Uno as a HID Keyboard

Guide based on: MitchTech


1. Download the HEX Files

Arduino Mega Firmware

Arduino Keyboard Firmware


2. Upload the Keyboard Code

/* Arduino USB Keyboard HID Demo
 * Cut/Copy/Paste keys + extra bindings for A, Z, E, R
 */
 
#define KEY_LEFT_CTRL 0x01
#define KEY_LEFT_SHIFT 0x02
 
uint8_t buf[8] = { 0 };  // Keyboard report buffer
 
#define PIN_COPY 5
#define PIN_CUT 6
#define PIN_PASTE 7
#define PIN_A 2
#define PIN_Z 3
#define PIN_E 4
#define PIN_R 5
 
int state = 1;
 
void setup() {
  Serial.begin(9600);
 
  // Initialize pins
  int pins[] = {PIN_COPY, PIN_CUT, PIN_PASTE, PIN_A, PIN_Z, PIN_E, PIN_R};
  for(int i=0; i<7; i++) {
    pinMode(pins[i], INPUT);
    digitalWrite(pins[i], HIGH); // Enable internal pull-ups
  }
 
  delay(200);
}
 
void loop() {
  checkKey(PIN_CUT, 27, KEY_LEFT_CTRL);   // Ctrl+X
  checkKey(PIN_COPY, 6, KEY_LEFT_CTRL);   // Ctrl+C
  checkKey(PIN_PASTE, 25, KEY_LEFT_CTRL); // Ctrl+V
  checkKey(PIN_A, 4);
  checkKey(PIN_Z, 29);
  checkKey(PIN_E, 8);
  checkKey(PIN_R, 21);
}
 
void checkKey(int pin, uint8_t key, uint8_t modifier = 0) {
  if(digitalRead(pin) == LOW) {
    buf[0] = modifier;
    buf[2] = key;
    Serial.write(buf, 8);
    releaseKey();
  }
}
 
void releaseKey() {
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8);
  delay(500);
}

3. Enter Debug Mode

  1. Connect Pin 13 → top-right for ~2 seconds (do not exceed 2 sec)
    Video guide: YouTube
    bf83f3b474ebb2b716c9e387b8f355ee.png

    when you see blinking it mean it is in debug mode

  2. Open Device Manager

    • You should see an Unknown Device (this is your Arduino in debug mode).
      b675c023d94ce6322ac5d48b50f8643d.png
      aa69cdb4495ae68b428a7718b91fc3f6.png
  3. Update the driver:

    • Browse to FLIP_directory/USB and update manually.
      daf5f072affa53b9263ff7aa61d6da5b.png
      291657925295c77fe7b5d5a34a7d1cc4.png
  4. After driver update, the device should look like this:
    22d772e3aff8114b6d4ac4b79a587211.png


4. Download FLIP

Download FLIP – the tool to flash your Arduino.


5. Flash Arduino to Keyboard

  1. Open FLIP → Load File → select the keyboard HEX file
    61da4c9a059a05166b6df4f80a1165af.png
    f7a1d7d2c3580da64496bab8d528eb4f.png
  2. Upload and test it on your Arduino.
  3. After flashing, your Arduino should act as a HID keyboard.

6. Restore Arduino to Normal

  1. Put Arduino back in Debug Mode
  2. Open FLIP → Load File → select the Arduino Mega HEX file
  3. Flash to return Arduino to standard firmware.