# Lock layer without the LED?

**URL:** <https://community.keyboard.io/t/lock-layer-without-the-led/672>\
**Category:** Programming\
**Created:** [November 3, 2017, 7:57am UTC](https://community.keyboard.io/t/lock-layer-without-the-led/672 "2017-11-03T07:57:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [November 3, 2017, 12:15pm UTC](https://community.keyboard.io/t/lock-layer-without-the-led/672/2 "2017-11-03T12:15:12Z")

</div>

A quick way to implement this would be a macro like this:

```auto
void togleNORMAN(uint8_t key_state) {
  static uint16_t blink_end;

  if (keyToggledOn(key_state)) {
    blink_end = millis() + 1000;
    if (Layer.isOn(NORMAN)) {
      Layer.off(NORMAN);
    } else {
      Layer.on(NORMAN);
    }
    LEDControl.setAllLedsTo(128, 0, 0);
    return;
  }

  if (blink_end && millis() > blink_end) {
    LEDControl.setAllLedsTo(0, 0, 0);
    blink_end = 0;
  }
}

```

The idea here is that when toggling the layer, we’ll set the leds, and record when the leds should turn off (1s after toggling on). When the key’s not toggled on, we check if we have an end time, and if we do and it is over, we turn the LEDs off. This does not blink, but show you a static color, mind you. Blinking can be implemented with reasonable ease. Or you could even add breathing… But those are left as an exercise for the reader! 😉

---

_[View the full topic](https://community.keyboard.io/t/lock-layer-without-the-led/672)._
