Go Down

Topic: LilyGo BadUSB - ATMEGA32U4 - Info & Pinouts (Read 5690 times) previous topic - next topic


Mar 24, 2019, 03:02 pm Last Edit: Aug 11, 2019, 01:17 pm by Nico_TheDecoder
Here is some info about LilyGo BadUSB and you are welcome to add more info about the subject.

After I bought some pieces of LilyGo BadUSB, my first thought was that the board should also be used for anything other than keyboard emulation and evil things.

But first, just a little info about keyboard emulation for non-US:
Finding a library for the Arduino IDE for my Keyboard Layout was a bit difficult, but found "Keyboard_DE" and it works: https://github.com/BesoBerlin/Arduino-German-Keyboard

I've tried searching the web for pinouts, schematic and similar.
But ended up separating one of my own LilyGo BadUSB board, and here are some pictures

Found out that it is an ISP connector that is inside and a red LED.

And here are the pinouts:

Pins in Arduino IDE (board is Leonardo):
SCK = 15
MOSI = 16
MISO = 14
LED = 13

Here near the screwdriver we have an LED.

Another picture of PCB

I have also tried playing a bit with SoftwareSerial and works fine with pins 14, 15, 16 (MISO, SCK, MOSI)

Board Specs:
Microcontroller: ATmega32u4
Clock Speed: 16 MHz
Operating Voltage: 5V DC
Digital I / O Pins: 4 (Onboard LED = 13, MISO = 14, SCK = 15, MOSI = 16)
Micro USB: 1
Flash Memory: 32KB, but 4KB used by bootloader (Caterina-Leonardo)
SRAM: 2.5 KB

Link for pictures in high resolution:

Stay safe and stay legal guys/girls!!


Jul 05, 2019, 12:07 am Last Edit: Jul 05, 2019, 12:08 am by BionicRiddle
Thanks! I did not know that there was a LED built-in on the board. I repurpose mine as a discord mute indicator using https://github.com/Oxmaster/Discord-mute-indicator
I remapped "Ctrl + <" to "Scroll Lock" using AutoHotKey
I changed some things in Oxmaster's code so it would use pin 13 on the LilyGo

Video: https://public.riddle.nu/cds/lt/discordindicator.mp4

Arduino code: https://public.riddle.nu/cds/lt/DiscordMuteIndicator.ino

Code: [Select]
/*  License
 *  Version 3, 29 June 2007
 *  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 *  Everyone is permitted to copy and distribute verbatim copies
 *  of this license document, but changing it is not allowed.
 *  see LICENSE.txt

/*  DiscordMuteIndicator
 *  Version: 1.0
 *  Date: 24.03.2019
 *  Author: Paul Oleszczyk
 *  Twitter: @oxmstr
 *  Email: paul.oleszczyk@gmail.com
 *  Github: https://github.com/Oxmaster/Discord-mute-indicator

#include <HID-Project.h>

// config ------------------------------------------------------------

/*  which LED will trigger the images
 *  possible choices:
#define triggerLed LED_SCROLL_LOCK

const bool mutedMicrophoneImageWhenTriggerLed = 1;            // LED on if triggerLed (scroll lock by default) is ON (1) or OFF (0)

// vars --------------------------------------------------------------

bool micState = 0;                                            // current status of triggerLed (scroll lock by default)

// functions declarations --------------------------------------------

void poll();                                                  // poll the status of the triggerLed
void updateLED();                                             // updates the LED, dependent on the micState

// main --------------------------------------------------------------

void setup()
  pinMode(13, OUTPUT);

void loop()

// functions ---------------------------------------------------------

void poll()
  micState = (BootKeyboard.getLeds() & triggerLed) ? 1 : 0;   // compare bit masks if triggerLed (by default scroll lock) is ON or OFF

void updateLED()
  static bool previousMicState = !micState;
  // if there was no change, there is no need to update the LED
  if (previousMicState != micState)
    if (micState == mutedMicrophoneImageWhenTriggerLed)
      digitalWrite(13, HIGH);
    } else
        digitalWrite(13, LOW);
    previousMicState = micState;

// I Love You

Code: [Select]

^VKE2::ScrollLock ; Discord Mute (remap Ctrl + < to ScrollLock
!VKE2::| ; Alt + < fix (Nordic keyboard)
<^>!VKE2::| ; AltGr + < fix (Nordic keyboard)




Thanks for the useful information. I somehow scred up the bootloader. The USB is not getting detected in my Linux Box anymore. tried with
Code: [Select]
Code: [Select]
dmesg -w
 command. no device detected. trying to use the SPI pins in order to upload the bootloader into the device.

Can you please upload the bootloader hex file?

Any suggestions in this regard will be of great help.
"Imagination is more important than knowledge."<br />-Einstein



So i've received a usb drive as a present that looks exactly like the one in Nico's post except it isn't labeled.
Since it seemed a bit suspicious i've decided to check it out in a VM. After about 5s it starts a cmd prompt and that's about it.

So..i don't have any Arduino or BadUSB experience but i'd like to turn this device into something useful like a security key necessary for the windows login.

So far i've disassembled the drive, downloaded and installed the Arduino IDE.

Is it possible to connect the pcb directly via USB to my laptop? I'd know where to connect the red and black wires but what about the white and green one?

Go Up