Projects/LEDs-GettingStarted

From Teesside Hackspace

Below is a quick overview to get started on electronics with LEDs, if you have questions ask on our slack group.

Low Power LEDs[edit]

Low power LEDs (Light emitting diodes), commonly in 5mm, 3mm or surface mount packages are a great start to electronics. To power them a series resistor should be used otherwise a small change in supply voltage can cause a huge change in current causing burn out.

Typically such LEDs are 20mA (0.02A), their voltage depends on their colour with Red typically being 2V and Blue 3.6V.

A 5V circuit with a 2V Red LED would need to drop 3V (5V-2V) over the resistor, using ohms law at 20mA this gives us: (5V-2V)/0.02A= 150Ohms so use a value higher than this.

An online calculator and bit more explanation can be found here: DigiKey Online LED series resistor calculator

High Power LEDs[edit]

High Power LEDs (eg 1W+) would waste a lot of energy (as heat) if a series resistor was used, so a current driver circuit should be used (such a circuit would be overkill for a low power LED). There are many pre-assembled modules available for this find one matched to the current requirement of your LED that is able to provide the voltage it your LED needs. There are also lots off of the shelf reflectors and lenses for high power resistors.

Over recent years COB (chip on board) LEDs have multiple LED chips all connected together in one package. In the case of White LEDs (which are actually Blue LEDs with a phosphor to produce the other wavelengths) the phosphor is added after the LED chips have all being connected together, making them look like one big LED.

For AC circuits a capacitive dropper (using the reactance of a capacitor to reduce the current flow without turning energy to heat) is typically used to reduce the current. More info on using a capacitive dropper can be learned from Big Clive, although we recommend avoiding mains DIY electronics for beginners, its good to learn the principles and Big Clive is a good place to learn.

RGB LEDs[edit]

RGB LEDs have a red green and blue LED all in one package. By varying the brightness of each colour more colours can be made.

To vary the brightness PWM (pulse width modulation) is generally used, this flashes the LEDs on/off faster than the eye can see and altering the duty cycle to changes the apparent brightness, eg if its flashing fast and on half the time and off half the time it will look half as bright as when it is on 100%, if its flashing such that its on a quarter of the time and off three quarters of the time it will appear to the eye to be 25% brightness. This can be done to each channel (R,G and B) simultaneously to produce more apparent colours. Microcontrollers are generally used to provide the PWM signals.

RGB LEDs can be bought on cheap self adhesive strips eg 5m long.

When controlling a large amount of LEDs (eg in a strip) a MOSFET is needed because a microcontroller can not source or sink much current. Pre-built controllers can be bought including ones that use an ESP8266 wifi enabled microcontroller compatible with open source projects like Tasmota or WLED

Note: Although strips of RGB LEDs are great for their decorative qualities, despite being LEDs they are not very efficient (due to having a resister dropper every LED, or every 3 LEDs on 12V ones). The inefficiency of the resister droppers add up significantly when you have 100+ LEDs, same goes for addressable LEDs (the resistors are internal on many addressables). The combination of inefficiencies, large quantities of LEDs and low voltages mean high current supplies are often needed, always add fuses.

Addressable RGB LEDs[edit]

Addressable LEDs allow each LED on a string to be controlled by a digital signal, thus each LED on a strip does not need to be the same colour allowing for much more effects.

Software libraries such as Adafruit Neompixel library (and https://github.com/adafruit/Adafruit_NeoMatrix NeoMatrix] have been written to allow users to write code without having to go too low level.

To allow users to control addressable LEDs on a higher level (Infact without writing any code) Projects like https://kno.wled.ge/ WLED do this, WLED can be controlled by its on web interfact/ app or from your smarthome (using a controller such as smartthings, node-red, or home assistant, or even integrated with some propitiatory systems like Philips Hue)

Some Features of WLED:

  • Over 100 effects
  • Over colour 50 pallets (plus can make your own pallets) -the effects then run in the colours from your selected pallet.
  • Runs on ESP8266 or ESP32 (ESP32 better for animations with more LEDs, my ESP8266 has been fine with 300LED)
  • Nice web interface (inc mDNS naming)
  • Full control via MQTT (need to activate MQTT in interfaces menu)
  • Works with WS2812b and many other protocols/ LEDs
  • Can control from Node-Red etc (via MQTT or WLED nodes)
  • Can define segments and have different animations in different segments
  • Can sync multiple units, or even go all out and sync to a track with XLights (free) software
  • Now also does 2D Matrix

Some useful WLED tips

  • Can be programmed with a web interface or with tools like Tasmotizer or ESPGUI, see the official installation page (note: ESP32 needs bootloader adding first).
  • Easy to get started with a Wemos D1 mini, this doesn't require a separate FTDI converter, just plug in the USB and prog. added a cheap level shifter (although can often get away without the level shitfter) + power (fused) from PSU, no fancy specific hardware needed.
  • For sending custom themes via MQTT you send the JSON data to "YourMqttTopic"/api . No need to manually format the JSON, you simply get the theme how you want in the web GUI, then save it as a preset then you can copy paste the JSON from the pre-set, easy.
  • In the LED setup you can set a (software) current limit, save you stressing the PSU accidentally (but don't forget to turn it up from default), set pin and number of LEDs here too.

WLED is compatible with the hyperion open-source ambient lighting -project for syncing WLED controlled lights to computer or TV video screens.

Further Reading[edit]

Element 14: A comprehensive guide to LEDs

WLED: Wiring pro tips

WLED: Long Data lines