GOLEM keyboard project

Underglow with LED strips

While LEDs on a keyboard, especially per-key RGB LEDs, are often associated with kids and gamers, they may have a useful function by indicating the active layer. Thus, while they are not necessary components of a keyboard, knowing how to choose, wire and program them may come in handy.

After reading this article you will be able to compare, choose and purchase LED strips for an underglow effect, wire it up to your controller or PCB and program it to achieve different effects e.g. in QMK firmware.

Different LED types for keyboards

There are individual LEDs for per-key effects or mounted on a PCB, there are THM and SMD LEDs, but in this article I cover underglow with LED strips, often used with handwired builds or as a hardware mod.

Heap of LED strips
Heap of LED strips

Addressable LEDs

Addressable LEDs contain a tiny microchip that understands a protocol sent over a single data wire (instead of using a wire per color).

Pic: WS2812B and SK6812 LEDs

Most popular LED models have this chip integrated in the LED chassis (WS2812) but the chip can also be placed exposed on the strip PCB (WS2811).

Exposed ICs usually handle more LEDs and can be cut accordingly (e.g. the WS2811's per 3 key addressing).

Pic: WS2811 with external and WS2812 with built in IC

The chip passes on the remaining data to the next LED, allowing them to be chained together.

This means, you can easily control the color of the individual LEDs on a strip through a single data pin of your controller. This is especially useful on a development board with few easily accessable pins, like a Pro Micro.

Choosing LED strips

There is a whole lot of different addressable LED strips available. They come with different LED densities, level of weatherproofness and in different lengths.

The multitude of these strips can be intimidating, let's see what factors to consider before placing an order!

LEDs supported by QMK

Unless you are a practicing masochist, it's safe to say you want a model with firmware support. At the moment, in QMK, these models are mainly WS2812 and SK6812 variants:

  • WS2811, WS2812, WS2812B, WS2812C, etc.
  • SK6812, SK6812MINI, SK6805
  • Pic: SK6812 LED

    LED strip nomenclature

    Looking for WS2812 on aliexpress you can find offers like: "1m 30 IP30" or "5m 144 IP67". Abbreviations lice ECO, RGBW, WWA may be attached to product titles. What do all these mean?

    Strip length

    The first value is usually the lenght of the strip expressed in meters: 1m, 2m, 5m.

    A full rail is usually 5 m (or 4 m depending on LED density). They are stitched together from 0.5 m pieces so on longer strips expect solder joints every 0.5 m.

    Pic: Solder joint on a LED strip

    The strips can be cut to the desired length. (Whilst everything can be cut in pieces, these LED strips will actually retain their functionality.)

    Pic: LED strips can be easily cut to the desired lenght

    LED density / LEDs per meter

    The second value is the number of LEDs per meter, common numbers are: 30/60/74/96/100/144.

    Pic: LED densities from 30 to 144 LEDs per meter

    While the light provided by a more dense strip may prove more homogenous, it may also dissipate considerably more power (see Power considerations below).

    60 LEDs per meter is a good choice for most projects.

    For context: 30 LEDs per meter means an LED for every second key/column, while 60 LEDs for every key/column, give or take:

    Spacing (from LED to LED)Distance (between LEDs)Strip width
    3010 mm
    6010 mm
    7412 mm
    9612 mm
    10010 mm
    14412 mm

    Strip width

    The number of LEDs per meter also defines the width of the strip through the arrangement of electronic components on the PCB.

    A general width of the most common strips with 30/60/100 LEDs per meter is 10 mm, while that of a 74/96/144 strip is 12 mm.

    (Adafruit's NeoPixel product family has a skinny form factor which is 7.5/10 mm wide. With removing the casing you can reduce this further to 5/7.5 mm.)

    PCB color

    Contrary to most fields of usage, the color of PCB is not just personal preference with lighting projects.

    A white PCB may provide a more diffused, uniform effect, where a black PCB provides a clearer defined point of light, making all the LEDs more singular.

    Water protection class

    The third value shows if the strip is waterproof: IP30 is not waterproof, IP65 has a silicone/epoxy coating on the face (retaining the self-adhesive tape on the back) and IP67/68 is practically inside a silicone tube.

    This protection is rather weatherproof since submersion in water is not recommended.

    Pic: LED strips dith different water and dust protection classes

    In general, IP30 is for indoor use, thus, this is your best bet for keyboard underglow. It's also cheaper and has better heat dissipation without the coating/sleeve.

    The silica gel, epoxy resin sealing or a silicone sleeve has an effect on the overall thickness of the strip as well: the thickness is increased from 2.13 mm to 3 and 3.85 mm, which may be a problem for low profile builds.

    SpecWaterproofSelf adhesiveThickness
    IP30noyes2.13 mm
    IP65yesyes3 mm
    IP67yesno3.85 mm

    RGBW, CW, NW, WW

    White color mixed from RGB components can be really... not white. RGBW LEDs (SK6812) try to mitigate this issue by adding a dedicated white component.

    CN, NW and WW stand for cold, neutral and warm white, respectively.

    Pic: SK6812 RGBW LEDs

    Other than the quality, RGBW produces white light by consuming considerably less power (up to 20-50% decrease).

    However, the W component is not supported by QMK at the moment. SK6812 RGBW strips work fine but you cannot utilize this feature.

    ECO type

    Some LEDs and strip models are branded as "ECO", e.g. "WS2812B ECO". What does this mean? Economic, i.e. cheaper to manufacture and lower price? Ecological, thus, environmentally friendly?

    I seems the answer is both.

    Pic: WS2812B vs. WS2812B ECO

    The WS2812B ECO uses the least power among the popular 5V versions.

    According to the specifications, the LEDs and chips on these strips have a different material, shorter warranty, and thus probably shorter lifespan. Also, the light emission characteristics of these LEDs are slightly different.

    WS2812WS2812 ECO
    IC tracepure goldadmixture gold
    Warranty36 months18 months
    Red Iv*400-700500-700
    Green Iv*1000-15001300-1800
    Blue Iv*200-400300-500

    (*These are not wavelenghts but "intensity values" (Iv). The intensity value of an LED is used to characterize its light emission, expressed in millicandella [mcd].)

    What these values tell us is that the lifespan of an ECO may be considerably shorter, and the RGB components are brighter with lower sensitivity to voltage (smaller Iv range).

    Price

    For comparison, let's see the prices of a 5 m strip with 60 LEDs per meter (5m 60 IP30). All offers include free shipping and were collected from Aliexpress on 2021-01-20:

    ModelPrice
    WS2811 ordinary$9.99
    WS2811 bright$19.40
    WS2812$20.51
    WS2812 ECO$13.98
    SK6812$34.27
    WS2815$27.88
    WS2815 ECO$23.79
    APA102/SK9822$38.39

    Power consumption

    Your USB port (or controller) can provide only a limited amount of current (max. 500 mA), thus, you don't want too much LEDs.

    Power consumption depends on the LED type, number and brightness of LEDs.

    The most popular ones in order of power consumption: WS2812B > SK6812 >= WS2812B ECO

    A good average is 20mA per moderately glowing LED, but this may be much more for LEDs with full brightness (60mA).

    The overall power consumption is hard to estimate because with animated lighting effects it changes all the time. In addition, producing different hues may require different amount of power too (WS2812B ECO is surprisingly efficient in producing blue).

    Usually, less than 20-24 LEDs are recommended for a project using a single USB port. (You have to incorporate about 25 mA for your controller into the 500 mA limit.)

    Idle power usage

    This may come as a surprise, but addressable LED strips consume power even when turned off (because of the chips).

    An idle 5 m 60 strip (300 LEDs) dissipates 5.00-6.43 W with the WS2812B ECO being the most efficient (5.00 W).

    The three most popular LED types dissipate 3.3-4.2 mA with the WS2812B ECO being the most efficient (3.3 mA).

    @@@ tablehttps://quinled.inf o/2020/03/12/digital-led-power-usage/

    W/300ledWS2812BWS2812B ECOSK6812APA102
    LEDs Off5.905.006.306.43
    LEDs Pure Red 100%25.5423.9021.2034.55
    LEDs Pure Red 50%15.1013.5013.2021.40
    LEDs Pure Green 100%25.5023.1021.2034.50
    LEDs Pure Green 50%15.0013.0013.1021.10
    LEDs Pure Blue 100%25.5014.2021.2034.00
    LEDs Pure Blue 50%15.409.1013.3020.90
    LEDs RGB White 100%65.0046.8049.0088.10
    LEDs RGB White 50%33.9024.8026.3045.40
    Effect 1 (Police All) 100%25.5018.6021.2034.50
    Effect 1 (Police All) 50%15.4011.3013.4020.20
    Effect 2 (Loading/Default (Orange)) 100%11.009.4010.1014.50
    Effect 2 (Loading/Default (Orange)) 50%8.206.908.0010.00
    Effect 3 (Rainbow) 100%25.5019.6021.0034.20
    Effect 3 (Rainbow) 66%18.4013.9015.7025.10
    Effect 3 (Rainbow) 33%11.508.4010.5014.50

    My choice

    Since QMK doesn't support the white LED in RGBW variants anyway, WS2811 needs 12V, and SK6812 is much more expensive (2-3x) than WS2812, I went with 1 m of WS2812B ECO with white PCB for $3.28.

    If you prefer the characteristics of SK6812 and don't mind the relatively hefty pricetag, choose accordingly.

    Wiring

    The default wiring is quite self-explanatory. Most strips have only three wires: VCC, Din and GND.

    VCC and GND are shared, they don't consume additional pins. And the Din, i.e. the data wire requires only one pin of your controller.

    Some strip types (e.g. WS2813) have four wires: two data wires are an attempt to mitigate the problem with failing pixels.

    Wiring tips

  • The order of the three pins can vary between different strip densities and batches. Always use the labels printed ON THE STRIP. Don't follow blindly an online wiring diagram!
  • Adding a ~470 ohm resistor (300-500 Ohm) between the microcontroller's data pin and the data input on the strip may prevent spikes on the data line that can damage the first LED.
  • In case of longer wires, this resistor should be close to the LEDs, not the microcontroller.
  • In non-keyboard related projects with a more serious power supply:

  • When connecting a strip to any LIVE power source or microcontroller, ALWAYS CONNECT GROUND (–) BEFORE ANYTHING ELSE.
  • Conversely, disconnect ground last when separating.
  • When using a DC power supply, or an especially large battery, add a large capacitor (1000 µF, 6.3V or higher) across the + and – terminals. This prevents the initial onrush of current from damaging the pixels.
  • With through-hole individual LEDs you may add a 0.1 µF capacitor between the + and – pins of EACH PIXEL. Individual pixels may misbehave without this "decoupling cap." Integrated LEDs on a strip have this capacitor already.
  • Programming in QMK

    The configuration and programming part is well documented.

    The RGB lighting feature is enabled by default, and only the data pin and the number of LEDs have to be set in config.h.

    @@@table

    Lighting layers feature

    Lighting layers is the feature which is able to indicate your layer states by lighting up the underglow in different colors. When it comes to functionality (over aesthetics), this is what you want.

    Below is an example but see the documentation for more details.

    Layer state underglow indicator example

    @@@example

    Conclusion

    WS2812B seems to be the natural choice for most people. It's the upgraded version of WS2812, has reverse connect protection (the power supply reverse connection does not damage the IC) and is relatively cheap.

    However, WS2812B ECO (on white PCB) might be the best choice with less power consumption and a considerably lower pricetag.

    Thanks for reading! Below you can find a more comprehensive list of LED strips. For more tips and project ideas check the KBD Magazine.

    LED and LED strip types used in keyboards

    As a summary, here are some often used LED strip types and their characteristics:

    WS2811. 12v. External IC. Addressable only per 3 LEDs.

    WS2812 - The reference. 5x5 mm LED size, one data wire, no reverse connection protection. Power hungry. The colors may be affected by voltage drops. Sensitive to higher temperatures.

    WS2812B. Updated WS2812 with reverse connect protection (data sheet).

    WS2812B ECO. Uses the least amount of power (-6-44%) with most hues and is cheaper.

    WS2812C. Anecdotally similar to WS2812 but with less power consumption (?). I've never seen this one. According to the data sheet much dimmer than anything else.

    WS2813. Updated WS2812B with dual signal wires for breakpoint resume function, thus, 4 wires. The failure of an LED won't affect the others (unless two consecutive LEDs are broken).

    SK6812. Dedicated white component. Voltage-independent color and brightness over a wide voltage range. I.e. the colors of the LEDs should not be affected by a drop in the supply voltage as much as they are on the WS2812B. Compared to WS2812B, SK6812 uses less power (-10-20%) and LED quality is said to be better. At higher temperatures SK6812 is less prone to fail. Still power hungry though and way more expensive (x2-3).

    SK6812 mini. Mini version of the SK6812 with 3.5mm*3.5mm LED size. Smaller size, lower brightness and power consumption. Recommended for per-key (i.e. many) LEDs.

    SK6812 mini-e. Same as SK6812 mini but intended for hand soldering (larger pads).

    APA 102. The brightest LED strip but uses the most power among the 5V ones (+20-40%). Expensive.

    WS2815. 12V. Signal break-point continuous transmission. About the double of power usage compared to 5V strips. This is rather for projects using longer strips, not for keyboards.

    Sources