Close

Digikeyboard with LEDs

danjovicdanjovic wrote 03/08/2020 at 20:25 • 1 min read • Like

I have just added support for LED status on Digispark Keyboard library.


Now to get the LED status is just a matter of calling the function

DigiKeyboard.getLEDs()

DigiKeyboard.getLEDs()  

and test for one of the 3 contants:

NUM_LOCK

CAPS_LOCK

SCROLL_LOCK

Just like in the example

// USB Caps Lock Led gizmo - Danjovic 2020
// Use modified version of DigiKeyboard library
// https://github.com/Danjovic/DigistumpArduino/tree/master/digistump-avr/libraries/DigisparkKeyboard
#include "DigiKeyboard.h"

void setup() {
  pinMode(1,OUTPUT);      // Digistump BuiltIn LED as output
}


void loop() {
  // Check the state of Caps Lock and change led accordingly
  if (DigiKeyboard.getLEDs() & CAPS_LOCK)
      digitalWrite(1, HIGH);
  else 
      digitalWrite(1, LOW);
  DigiKeyboard.delay(10);
}

The modified version of the libraries are available at:

https://github.com/Danjovic/DigistumpArduino/tree/master/digistump-avr/libraries/DigisparkKeyboard

It is necessary to get the 3 files below...

The latter file enhances the keystroke definition of the original project and defines full set of HID Keycodes (from 0x00 to 0xE7).


.. and copy the files to the following path

c:\Users\__name_of_your_user___0\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\
Like

Discussions