# HID Emulation with Digispark ATtiny85

> USB keyboard emulation on a $2 chip

By Zsolt Bizderi · Published 2025-09-28
Canonical: https://ambientnode.uk/hid-emulation-with-digispark-attiny85

The Digispark ATtiny85 is a tiny, low-cost microcontroller board that can act as a USB HID. This means you can make it behave like a keyboard and automatically send keystrokes or commands to a computer as soon as it's plugged in.

In this post, I'll walk through setting up the board, installing the right drivers, and flashing a simple HID payload.



![](/media/2f8681c1-7382-426f-b3ef-0dbcc060c617/500.webp)



> Disclaimer: This guide is for educational purposes only. BadUSB techniques can be misused, so do not run payloads on systems you do not own or have explicit permission to test.

A HID emulator like this can be used for many applications, including:

* Security awareness demos: Show staff how untrusted USB devices can pose real risks
* Automation: Preprogram repetitive keystrokes or quick shortcuts on test machines.
* Teaching tool: Great for demonstrating microcontroller programming and USB HID behavior in classrooms or workshops
* Red team exercises: In controlled, authorized environments, illustrate how BadUSB-style attacks work in practice

---

## Step 1: Install Digispark Drivers

First, install the necessary Digispark drivers from here:



<a href="/media/f4579ab4-68cc-47c5-b678-9945968bf00b/Digistump.Drivers.zip" download>Digistump.Drivers.zip (1.6 MB)</a>


---

## Step 2: Add the Board Manager URL

1. Open Arduino IDE.
2. Go to File > Preferences.
3. In the Additional Board Manager URLs field, paste this link:

```
http://drazzy.com/package_drazzy.com_index.json
```

---

## Step 3: Install Digistump AVR Boards

1. Open Tools > Board > Boards Manager.
2. Search for **digistump avr boards**
3. Select the package and click Install.

Use this package and not `attinycore`, as this includes HID drivers. The USB drivers should also install automatically. If not, use the drivers linked in Step 1 to install them manually.

Once installed, set your board to:

```
Tools > Board > Digispark (Default - 16.5 MHz)
```

Do not plug in the ATtiny85 yet.

---

## Step 4: Write Your HID Code

Here’s an example script that opens a Run dialog, opens a site in Edge, then closes it:

```
#include "DigiKeyboard.h"

void setup() {
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.delay(500);

  // Win+R
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(400);

  // Open a benign training page (static query only)
  DigiKeyboard.print("msedge https://ambientnode.uk");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);

  // Give the browser time to launch
  DigiKeyboard.delay(5000);

  // Close tab
  DigiKeyboard.sendKeyStroke(KEY_W, MOD_CONTROL_LEFT);
}

void loop() {}
```

---

## Step 5: Compile and Upload

Uploading to the Digispark is slightly different than other Arduino boards:

1. Click Upload in Arduino IDE.
2. Only after compilation starts, a prompt will be shown to plug in the Digispark ATtiny85.
3. The flashing process will run automatically.

---

## Notes & Limitations

* Running commands like `cmd` or `powershell` is often blocked by antivirus software (flagged as Trojan, understandably).
* Be mindful of startup delays; tune `DigiKeyboard.delay()` values for reliability.
* The DigiKeyboard library assumes a US layout. If you’re on a UK or other layout, special characters like `@` or `"` might come out wrong.

---

## 3D-Printed Enclosure

You can house your Digispark in a fake USB stick case. Here’s a great printable model: [Digispark ATtiny85 Enclosure (Bad USB Stick Fake)](https://www.printables.com/model/509019-digispark-attiny85-enclosure-bad-usb-stick-fake-me)
