Go Down

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

Nico_TheDecoder

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:
+5v GND RST SCK MOSI MISO

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)
https://www.arduino.cc/en/Reference/SoftwareSerial


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
EEPROM: 1 KB

Link for pictures in high resolution:
https://drive.google.com/drive/folders/1NFCk_8VjjQSnWvtUBjm2BaI0zoQtvpTG

Stay safe and stay legal guys/girls!!

BionicRiddle

#1
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
 *
 *  GNU GENERAL PUBLIC 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:
 *
 *  LED_NUM_LOCK
 *  LED_CAPS_LOCK
 *  LED_SCROLL_LOCK
 *  LED_COMPOSE
 *  LED_KANA
 *  LED_POWER
 *  LED_SHIFT
 *  LED_DO_NOT_DISTURB
 */
#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);
  BootKeyboard.begin();
}

void loop()
{
  poll();
  updateLED();
}

// 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]

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

<3

Go Up