Lighting models V: Controlling and automating LEDs

Welcome to my article on model lighting! I cover different technologies that are useful for people who want to illuminate scale models of various kinds – cars, spaceships, dollhouses, etc.

And I don’t mean shining external lights on the model, of course. I’m referring to the technology to make tiny light sources that appear to-scale with the model itself.

The previous sections have dealt with LEDs and other types of light sources. This section discusses some of the tools for automating and controlling groups of LEDs.

CHAPTER CONTENTS

Controlling LEDs

Since LEDs are easy to turn on and off – they don't require any strange power sources or anything – it's easy to make an electronic device that can control a group of LEDs in a sequence, or on a timer, or whatever you want. There are thus many ways of automating light sequences that benefit a model maker.

For completeness I'm going to start off talking about analogue electronics. But, to be honest, these devices are really limited. I would focus on microcontrollers, personally.

Circuit boards for blinking

People have been designing simple electronic circuits to make LEDs blink for as long as there have been commercial LEDs. Early designs used relays, or a pair of transistors pointing back to back. Since the 1970s many blinky circuits have used now-venerable 555 integrated circuit timer chips.

Personally, I'd avoid these traditional solutions unless you have a very simple special purpose application, such as the alternating lights on a railway crossing gate. Or unless you want to learn more about the fundamentals of analogue electronics. The circuits add extra size and expense, and also draw current themselves, which costs battery life if you have a portable model. And they're just not terribly flexible compared to what computers can do these days.

I'd either use totally simple self-blinking LEDs, or else go for a full-on automated solution, using a microcontroller (see below). Microcontrollers have the same problems of bulk and power drain as 555 timer circuits, but offer vastly more sophisticated timing options!

Decade counter and 555 timer

A more advanced 555-based design adds a counting chip. Very simple boards containing this pair of small integrated circuits can be bought cheaply from online auction sellers and the like. These let you attach up to ten LEDs and flash them in sequence. The 555 timer chip determines the rate at which power goes from one LED to the next, and the decade counter chip simply counts to ten in a loop and resets. You can even make one of these circuits yourself – they're a simple electronics project.

This sounds really boring, and only useful for chase lights around a movie theatre sign for a model railway or something. But clever design lets you build a hardcoded board that supports various kinds of light patterns. For example, you could set up the board with two LEDs that alternate like a railway crossing gate, with a fifty/fifty on/off cycle. Or you could set the lights to stay on for, say, 2 time units out of 10, and then stay off for the remaining 8. Or you could simulate a three-colour traffic light, and have different colours stay on for different lengths of time. There are premade boards which are readily available from auction sites and hobby shops, sold for specific model-making applications such as a simulated traffic light, which work this way.

Such boards might be useful for certain models, but again, I find them really lacking. They're basically 1980s technology. First, you don't really have a ton of control as you can't address the blink rate of each LED - the chips just loop in a sequence at the same speed. Some boards have potentiometers that let you change the speed, but not on the fly, as it were. Second, 10 LEDs isn't really enough for sophisticated looking cockpit setups and the like. And third, the boards are a bit big for small models.

Custom driver boards for effects

A number of small or cottage industries produce circuit boards which control LEDs for specific effects. These are common in the world of model railroading.

For example, flashing lights on emergency vehicles in real life, especially the ones built before the advent of powerful LEDs, often consist of tinted glass or plastic domes containing motorized reflectors. These reflective dishes spin, bouncing light around like the beam of a lighthouse. Therefore the output of one of these lights will brighten, then flash full brightness as the reflector points at the viewer for a split second, then dim again.

This is a different from an LED that simply flashes on and off, or which brightens and dims rapidly. You can get circuit boards that control an LED to simulate this brief flash of light, along with the bright and dim part of the cycle.

Even fancier boards can control multiple LEDs grouped together, so you can simulate the rotation of the light – perfect for a large model of a lighthouse, say. Boards for simulating the rotating nacelle tips on Starship Enterprise models can also flash lights in sequence like this. Another popular board design flashes a blue-white LED brightly on an irregular basis, simulating a welding blowtorch. These special purpose boards are a little bit expensive for what they are, and probably make most sense as part of large-scale hero models than big dioramas or whatnot.

But now it’s pretty straightforward to hook an LED to a microcontroller and write a short program to achieve the same effects. This technique is much more flexible, but obviously requires more work than just buying a board and hooking it up! More on that approach further in this document.

Microcontrollers – the ideal solution

Okay. Enough with 1980s technology. The ideal setup would be a computer with output control over a bunch of electrical connections. Such a device would let you specify the brightness and timing of each of  your LEDs totally independently.

You could, for example, write a simple program that loops forever and turns an LED on and off. You could specify the exact number of microseconds that an LED is lit, which means you could make any pattern you want. A simple on/off flashing pattern with equal time on and off would be dead simple. A light that pulses briefly every second or so, like the strobe warnings on an airplane, would be just as easy. And you could set up different loops to control different LEDs or groups of LEDs.

Well, we now have affordable microcontrollers which can do all that and more! These are by far the most flexible way to implement sophisticated lighting in a model. A microcontroller is a self-contained computer on a single chip. Hobbyist microcontrollers are usually single boards which lack USB and video output, and so can’t be used like a normal personal computer, but which can control a variety of other outputs and receive different types of inputs.

Different lighting modes

A useful thing about using a microcontroller for lighting is the ability to create different settings or modes. For example, you could have a series of different states for a spaceship model. Let’s say mode one is landing lights on. Then you could have mode two being engines running, and mode three being a landing sequence. You’d put a concealed pushbutton on the model to cycle through the modes.

Or you could put a light sensor into your model railway. When the room lights are on most of the layout's building lights could remain off, but the traffic lights would operate. In night mode, determined when the room lights are off, the house lights could go on and off at random to simulate people moving around the house, car headlamps could illuminate, traffic lights would continue to operate but perhaps at longer intervals, and so on.

For this type of sophistication to work you’d have a bit of code that increments a counter variable each time you press a pushbutton wired to a button input on the controller. Or checks to see what a light sensor is reporting. You’d then have a series of loops for each type or group of lights, and the loops would check the value of the counter to see what mode the controller is currently in.

Types of microcontrollers

There are tons of such small computers out there, with Arduino and Raspberry Pi educational devices being the most popular. These are quite powerful and have a variety of outputs – the Arduino Zero shown below, for example, has 20 separate connectors. And many such microcontrollers (such as the Arduino Pico, the PJRC Teensy and the Raspberry Pi Zero) are absolutely tiny and easy to fit inside a model. The small ones in particular are quite affordable.

However, I deliberately don’t focus on Arduino and Raspberry Pi and related devices here. Not because they’re bad products. To the contrary – they’re awesome devices that have revolutionized the world of hobbyist computing. But most of them feel like overkill to me as a model-lighting solution. I also think they're tiresomely fiddly to set up for inexperienced users, and the languages aren't easy to learn.

Instead I focus on two lesser-known products designed as children's educational devices. In recent years there have been a lot of products released to help schoolkids learn the fundamentals of computing, and many of these things are remarkably full-featured. There are tons of these things out there now - the Seeed Grove, chibi chip, beaglebone, Gumstix... many more. But there are two that I think are well suited for model makers: the BBC micro:bit and the Adafruit Circuit Playground Express (CPX).

The BBC micro:bit is a tiny educational computer that was distributed for free to British schoolchildren, and is readily available online. The Adafruit Circuit Playground Express is a product of hobbyist electronics experts Adafruit, of New York.

Child's play

Some people may be surprised that I suggest using children’s educational microcontrollers, instead of arguably more advanced and much more popular products such as the Arduino, for model building. But I think the kids’ computers are great, because they:

The kids’ devices fit neatly between non-automated solutions such as hooking up a few self-flashing LEDs to a battery, and more advanced solutions involving more powerful computers which require full-on textual programming languages.

In short, I think of educational microcontrollers as being a fast and convenient means to an end - that of simple control over model lighting.

Making a blinky light using a BBC micro:bit or an Adafruit Circuit Playground Express.

Here’s an example to show how easy it is to implement a flashing light using one of these children’s educational microcontrollers. To keep things simple we're going to use one of the on-board LEDs that's soldered onto the device. The LED will pulse twice briefly, wait for a second, then repeat again in an endless loop. Maybe it'd be good for a warning strobe on a model vehicle. 

These are the steps to do it.

Sketch a flowchart on paper:

It can be useful to write your planned sequence of events on paper first. For example:

Go to your device’s programming page:

Both the BBC micro:bit and Circuit Playground Express devices are programmed using special web pages. These pages don’t work very well on tablets and phones, so fire up your personal computer.

If you’ve got a BBC micro:bit then go to:

https://makecode.microbit.org/

If you’ve got a Circuit Playground Express then go to:

https://makecode.adafruit.com

Write the program:

Next, drag colour-coded programming blocks from the left side of the screen onto the programming area on the right. The blocks are easily moved across the screen, and click together like Lego bricks.

If you’ve got a micro:bit then your final program should look like this. The “plot” commands turns on an LED at the x and y coordinates provided, and “unplot” turns it off. The “pause” command simply waits for the number of milliseconds that you specify. And “forever” means that the group of commands just loops round and round indefinitely.

And if you’re using a CPX it should look like this. It’s a similar set up of instructions, but you can specify the dot colour by clicking on the oval. Since the CPX hasn’t got a grid of lights you specify the light number in the ring of LEDs.

Test the program:

Both web pages have a built in testing program. This shows you a picture of the device, and clicking the triangular “play” or "run" button will make the simulated on-screen device emulate the behaviour of the real thing.

Make sure the simulated blinky light in our example does what it's supposed to do.

Download the finished program:

When you’re happy that your program is doing what it should, you'll want to transfer it to your personal computer by clicking the pink or purple "Download" button. It will then be ready for copying onto your microcontroller device.

(note: earlier versions of the micro:bit software had a button labelled "compile" and not "Download")

Depending on what computer and browser settings you have, clicking one of these buttons will transfer the finished program to your "Downloads" folder or somewhere similar.

Copy the program:

Plug your device into your computer using a normal micro USB cable, like many older phones. If you're using a CPX, press the RESET button.

The device will appear on your computer’s desktop, just like a hard drive or whatever. The micro:bit device appears under the name "MICROBIT". The CPX device appears under the name "CPLAYBOOT".

Note: older versions of Windows may require installation of drivers if you're using a CPX. If the device doesn’t appear try another cable - some micro USB cables are charge only and don’t carry data.

Find your downloaded program (it should be in your computer's default downloads folder) and copy it onto the device by dragging it over.

If you have difficulty with this step, the micro:bit's download instructions are here.  The CPX's download instructions are here.

Run the program:

Unmount or eject the microcontroller's drive from your personal computer. Then plug the device into power (battery or USB) and, if necessary, restart it.

Your program will now be running on the device. That's all there is to it!

Use the program with a model:

Since the program has been copied onto the device's flash memory it will remain there indefinitely. You can unplug the microcontroller from power and it won't lose your program. This means you can install the device inside your model and it'll run your program whenever you turn it on.

Details on programming

Different programming languages are available for both the micro:bit and the CPX, but the easiest and most accessible is the TouchDevelop/MakeCode "block" language developed by Microsoft. This system, shown above, is derived from the "Scratch" language developed at MIT.

I like it because, although it's a simple system designed for kids, it offers you two choices for programming. First, you can move visual snap-together blocks around on your computer’s  screen, as described above. This is a quick and simple way to prototype some basic functionality, though it does get cumbersome for anything complex.

Check out the simple micro:bit example below, which displays a message upon button A being pressed.

Second, you can switch to a text window and type up your instructions using a variant of the JavaScript programming language. This lets you access almost the full functionality of the device, and gives kids an easy introduction to proper text-based coding. Indeed, the software lets you switch back and forth between a visual block representation of your code and a text representation of the same code – how awesome is that? It’s also easier to copy and paste text for repeated commands, instead of repeatedly dragging blocks.

The example below is the exact same program as the previous screenshot, only in textual Javascript form.

Making the educational devices even more awesome, you can instantly test your code using an on-screen simulator, as described above. You don't have to mess around transferring the software to a physical device, finding it doesn't work, fixing the bug, transferring it back, and so on. The simulator can show you your basic flashing lights immediately.

Other key points about this technology:

There are a few points here to keep in mind.

Two micro:bit example programs

Here are a couple more demo block-diagram programs for the micro:bit. First, a super-simple program that turns on three LEDs, shows them for half a second ("500 ms" is 500 microseconds, or 500/1000 sec), turns them off, waits a whole second, and then repeats indefinitely.

Note how the micro:bit software can show a 5x5 grid of lights, and you simply check off the boxes that you want to light up. You can't specify a colour since the micro:bit only has red LEDs.

Or take something a little more complicated. Let's say you want a single LED in the corner to light up for 1/2 second, then stay dark for a random period of time. The random time must be at least 1/2 second, and can be up to another 4 seconds in 1/2 second increments. You can specify your LED directly, and you can perform simple math in your code as well.

The great thing is that both of these mini programs – blink 3 LEDs, and blink 1 LED at random – can run separately and independently of each other on the same micro:bit, resulting in the possibility of fairly complex behaviour! This is perfect for a control panel, say, which looks like it's actually doing something rather than just flashing simple timed lights.

An animated light example for the Circuit Playground Express (CPX)

Now let's say you have a spaceship model, and you want to have some flashing lights on its hull. Maybe you want port and starboard strobe lights which briefly flash two LEDs for 0.1 seconds every 1 second. One is red and one is green, and they blink at full brightness. Second, you want a third LED which glows white at half power, and simply turns on and off every 1 second. And you intentionally don't want the two strobe lights to synchronize with the white light at all.

Here's a simple pair of programs which take advantage of the CPX's full-colour lights. LEDs 0 and 9 briefly pulse red and green respectively, and LED 5 steadily blinks white.

Or let's say you want to make a double row of flashing yellow lights, like the one at the bottom of the bridge display monitor on the Starship Enterprise. You can do so using visual blocks, as above. Or you can type in a traditional text-only Javascript program, like this:

forever(function () {

    light.clear()

    light.setPixelColor(0, 0xffff99)

    light.setPixelColor(9, 0xffff99)

    pause(250)

    light.clear()

    light.setPixelColor(1, 0xffff99)

    light.setPixelColor(8, 0xffff99)

    pause(250)

    light.clear()

    light.setPixelColor(2, 0xffff99)

    light.setPixelColor(7, 0xffff99)

    pause(250)

    light.clear()

    light.setPixelColor(3, 0xffff99)

    light.setPixelColor(6, 0xffff99)

    pause(250)

    light.clear()

    light.setPixelColor(4, 0xffff99)

    light.setPixelColor(5, 0xffff99)

    pause(250)

})

An actual computer like a CPX gives you complete flexibility and control over your lighting, compared to a simple 555 circuit. And, so long as 10 multicolour LEDs is enough for your needs, no complicated soldering or wiring is required!

The BBC micro:bit hardware

Here's the BBC micro:bit - a tiny one-board toy computer designed to teach programming to schoolchildren. Millions were given away for free to year 7 kids across Britain in 2015.

Its three main features are:

But there's a lot of hidden functionality as well.

The Circuit Playground Express hardware

American maker company Adafruit have developed a small round computer, the Circuit Playground Express, that's quite similar to the BBC micro:bit. The key differences are:

The CPX's built-in colour support is perfect for lighting models. Unfortunately they're RGB lights, not RGBW, so they don't offer the greatest white light output, but they sure beat plain red. However compared to the micro:bit you have fewer individually controllable onboard LEDs (10 versus 25), which may or may not balance out the fact that you get colour – it all depends on your needs.

Note that you want the Circuit Playground Express, not the earlier Circuit Playground (also known as Circuit Playground Classic) product which doesn't support block coding.

A really important note if you want to do the block-based MakeCode programming is that there's also a newer version of the Circuit Playground, called the Circuit Playground Bluefruit. This board uses the  nRF52840 chip, which at time of writing does not support MakeCode programming! This may change someday, so be sure to check the Adafruit website before buying.

On-board LEDs for model lighting

If you can position the board close to your model cockpit or wherever you want the blinkies, it's really easy to use the device as a fibre optic light source. Just put a blob of clear epoxy on each LED and hold the fibre in position with a clip or something while the glue hardens. Or, if you want a less permanent solution that makes it easy to swap out the device, take a square of plastic drilled with holes and fasten it over the board.

External LEDs and microcontrollers

It's also easy to control an external LED using one of these microcontrollers. They have external connectors, called "pins" although they don't actually stick out, to which you can clip or solder wires. These pins can power an LED, though you'll need to add a resistor into each circuit to prevent the LED from being blown out by too much current.

Here's an example for the BBC micro:bit. You use the "digital write pin" command to light up the LED. In fact, since the micro:bit has three main output pins you can control three separate LEDs at a time. If you use an edge connector, which adds easy access to some additional pins, you can control more. The CPX has eight main pins which can drive external LEDs. (GPIO for general purpose input/output)

These pins do not allow you to directly connect multiple sets of LEDs, however. This is because the maximum power output of these microcontrollers is very limited, to save on battery power. If you want to control multiple sets of LEDs you'll need to add some transistors and an external power source. Or you could use Neopixels - see below.

Dimming LEDs and PWM

What if you want to reduce the brightness of an LED? LEDs are actually difficult to control in terms of light brightness - they don't dim easily the way light bulbs do. So a common technique is to pulse the LED on and off at a really high frequency. If you do so fast enough the human eye can't tell that it's blinking, and just thinks the LED is a bit dimmer. By varying the length of the pulses you can simulate changes in light output.

This is normally done through "pulse width modulation," or PWM. So an LED that's pulsed on for 50% of the time, then pulsed off for the remaining 50%, will appear to have half the light output. It's all more complex than that, since the sensitivity of the human eye isn't linear, but you get the idea.

PWM is also used to make simple beepy noises using speakers, or to control servomotors.

Both the micro:bit and CPX devices support PWM, though not on all output pins and at all times.

https://www.iot-programmer.com/index.php/books/27-micro-bit-iot-in-c/chapters-micro-bit-iot-in-c/48-micro-bit-iot-in-c-pulse-width-modulation-servos-and-more

https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-pwm

https://learn.adafruit.com/circuitpython-basics-analog-inputs-and-outputs/pulse-width-modulation-outputs

Servomotors

One of the cool things about educational microcontrollers is how easy it is to control motors with them, since they have PWM output control. The micro:bit even has a nice visual representation of a servomotor when you write a program that uses one:

Servomotors are a special type of motor which can be commanded to rotate to specific positions, rather than having a shaft that spins round and round. This example will rotate a servomotor to a zero degree position if button A is pressed, and to 180 degrees if button B is pressed. And if you use a small servomotor you can actually power it by the microcontroller itself, just as shown.

Servos like this are perfect for making small robots, for animating a creepy doll head, for making a motorized crossing gate for a railway – anything you can think of, really!

Drawbacks of educational microcontrollers

Educational devices like these are designed within tight constraints to keep the costs down. They aren't meant to be as fully featured as most other microcontrollers or small computers. Here are the main drawbacks for a model maker.

What about more advanced microcontrollers?

A number of companies are using easy to program drag and drop code systems now. One microcontroller product line that's quite interesting comes from m5stack. They make a vast range of clip-together microcontrollers and add-on devices that can do all kinds of fascinating things, and you can program them using a simple graphical system. This line of CPUs is much more capable than a small educational microcontroller for the kiddies, yet is still easy to use.

https://flow.m5stack.com/

Smart LEDs: WorldSemi addressable LEDs/Neopixels

Normal LEDs are just on/off light sources. They produce light when power is applied to them, and fall dark when it isn’t. Can’t get any simpler than that!

But what if you want to have a whole bunch of separate LEDs, all automated and controlled individually? If you were to connect each individual LED to a single output pin on your microcontroller you'd soon run out of pins! Even the most advanced microcontroller board won't have more than a couple dozen pins, and even then you'd have a spaghetti of wires running to each light.

The traditional approach to this problem is to have your LEDs arranged on a grid or matrix of wires. You might then have additional circuitry along the edge of the grid, sending power to each LED that’s supposed to light up. This is how older illuminated digital signs work. However having all the wiring is obviously complicated and expensive.

But what if you were to invert the design? What if you tucked a tiny computer chip inside each LED itself? Then you could have a whole bunch of LEDs strung together on a powered line. And each “smart” LED would only light up when a computer spoke to it directly. By putting three coloured diodes into each LED you could also specify the precise output colour in terms of red, green, and blue values. This is the basic premise behind individually addressable LEDs.

Various companies had tried such systems, but in 2011 Chinese manufacturer WorldSemi developed its WS2812 series of smart LEDs. This was a line of easy to use and affordable LEDs containing semi-intelligent driver chips. However, because WS2812 is a supremely unmemorable name, US retailer Adafruit came up with the name Neopixel to refer to such "smart," or addressable LEDs. Other names exist - Kitronik calls them ZIP lights, for example.

Regardless of what they're called, they're three-colour or four-colour LEDs with a built-in digital controller chip, making it possible to command specific LEDs that are all wired in a string. If each LED is a tricolour device you can specify colour and brightness for every single point of light on your string. So instead of a spaghetti mess of cables, with every single LED requiring its own two wires leading back to the power supply, you can get things down to three wires across the whole project - two for power, and one for signalling. Here's a stick containing eight Neopixels.

Such technology offers incredible flexibility for model makers. You could have a curved strip of LEDs at the back of your Millennium Falcon model, and have the lights go through a timed sequence of red to blue to bright white, simulating the engines starting up. Or you could run a long string of individual LEDs through a whole bunch of houses in your model village, timing them so they go on and off at random time intervals. Or you could put warm white LEDs into each lamp in your doll house and have them light up and go off in a carefully predetermined sequence. Individually addressable LED technology is a great way to implement all of these things and more.

Each Neopixel has to be soldered up to those three wires (and also to a capacitor, in the case of WS2812 chips). They do nothing hooked up like this - they won't even light up - but you can then use a microcontroller to command each device. Want the first LED in the string to glow red at 50% brightness? You can. Or the third one at 100% green? No problem!

Not only do you have a reduced number of wires, but you can control the individual shade of colour and brightness for each LED on the string, making automation possible. Since most Neopixels contain red, green, and blue LEDs, and you can dial in any combination of relative brightness between the three, you can specify any of 1.6 million colour combinations. Each LED can also glow at one of 256 brightness levels, via PWM pulsing.

RGBW Neopixels also include a fourth white LED (there are three types of white available - cool blue, warm yellow, or "natural," which is sort of halfway) for a more accurate white that isn't an approximation composed of red, green, and blue LED output.

Chains can include huge numbers of individual pixels. You're theoretically limited by the amount of power you have, and the amount of memory (RAM) in your microcontroller, though in reality you'll probably hit refresh limits before then. And in terms of power they’re moderately tolerant of a range of different voltage levels, since they have on-board current regulators.

Neopixels and educational microcontrollers

The micro:bit and CPX, despite their simplicity, can actually be used to control Neopixel LEDs, making them a perfect and fairly straightforward solution for controlling complex and automated arrangements of light. In fact, the CPX uses Neopixels for its onboard LEDs! Neopixel software is also integrated into the MakeCode block language, making the LEDs simple to control.

MakeCode for the micro:bit requires you to add the Neopixel support software by clicking on the "Add Package" link.  The CPX software, on the other hand, already has Neopixel support enabled – just click the "Light" button and the "Neopixel" link appears. You can then use the "create strip" feature to instruct your CPX that you have an external set of Neopixels connected.

Compared to other technology used for lighting models, the primary drawbacks of Neopixels are the extra complexity of programming, the additional cost of the chips, and the relatively high current draw of the LEDs. A bunch of Neopixels all producing light at full blast can consume a tremendous amount of power, depleting batteries rapidly. There are low-current chips available, but Adafruit and most other supplies don't carry them, and they’re generally very difficult to find for some strange reason.

Neopixels are mostly half a centimetre square, though some are 3.5mm square. This isn't as small as really tiny SMD LEDs, which does limit where they can be placed. On the positive side, they're sold in a variety of configurations, from sticks to panels to strings to rings to individual chips. You can even buy add-on modules, which clip directly to a micro:bit, that have rows of Neopixels built in. Check out the ZIP Halo below - it's a circular ring of LEDs which screws right onto a micro:bit. Neopixels attached to boards and strips generally have necessary support components as well — single WS2812 Neopixel LEDs require additional capacitors and resistors soldered to them.

A more subtle problem with WS2812 Neopixels is that they pulse their output at a fairly low rate, like the micro:pixel's onboard LEDs. This is usually not too objectionable to humans, though it will cause strobing if the LED is moving, but can cause problems when shooting motion for video and movies. The pulsing is more apparent when at the lowest brightness settings, since the percentage of time that the LEDs are on is very low. The WS2813 chips have a higher refresh rate.

Types of Neopixels

Although Neopixel is Adafruit's well-known branding for these products, as noted earlier the technology was actually created by Chinese manufacturer WorldSemi. It's therefore possible to see these products sold as the WS2812 and WS2813 (the whole LED device) and the WS2811 (just the driver chip which can control LEDs).

The WS2813D is the ideal one for battery projects, since it's got a high refresh rate and low power consumption. But weirdly it's almost impossible to find! It's also not available in an RGBW version, sadly, since the manufacturer says there's no demand.

Most chips of this type only available in a  5mm x 5mm package, though some are also available in a 3.5mm x 3.5mm package.

WS2811

Controller chip only. No on-board LEDs.

WS2812

5 x 5mm package. RGB, 20 mA each. 400 Hz refresh. Requires external capacitors.

WS2812B

The WS2812 with reverse current protection circuitry. Slightly brighter LEDs.

WS2812C

Low current version of the WS2812B. 5 mA per LED. 2 KHz refresh.

WS2813A

WS2812B, but a failed chip will no longer break the chain. 2 KHz refresh rate. 16mA per LED. No external capacitors or other components required!

WS2813B

Slightly cheaper, lower brightness version of WS2813A.

WS2813C

Low current version of 2813A. 5mA per LED

WS2813D

Low current version of 2813B, higher brightness. 5mA per LED

SK6812

Clone of the WS2812, but with 1.1 KHz refresh.

SK6812mini

Same as SK6812, but in a 3.5x3.5mm package.

A useful technical article on the WS2812.

Advanced tech: I2C

If you're looking for more advanced control over devices, both the micro:bit and the CPX support the I2C protocol. This is a technology that allows your microcontroller to send commands to another device, such as an MP3 player or external sensors or whatever. The micro:bit also supports SPI.

This is moderately advanced stuff, however, so I'm not going to go into detail about it here, other than to mention that it exists.

https://microbit-playground.co.uk/howto/attach-microbit-to-I2C-devices

https://smalldevices.com.au/blogs/resources/connecting-i2c-devices-to-the-bbc-micro-bit

https://makecode.microbit.org/reference/pins/i2c-read-number

https://learn.adafruit.com/circuitpython-basics-i2c-and-spi/i2c-devices

Why not an Arduino device?

So after all this, why not an Arduino microcontroller? Well, there are two basic views on this.

Viewpoint 1: Arduinos are great!

Arduino and compatible devices are probably the most popular hobbyist microcontrollers out there, and a lot of model makers rely on them for advanced lighting control. They're powerful, flexible, cheap, and many are extremely compact.

They're also getting easier, theoretically, to set up and program. This is the Arduino IDE (integrated development environment):

There's some amazing stuff out there that's been done with Arduino-type gear, and the possibilities are endless. Take, for example, the Adafruit Flora - it's a small board compatible with the Arduino IDE that can drive up to 50 Neopixels. Or insanely tiny microcontrollers like the Adafruit Trinket or the PJRC Teensy.

And in fact, if you go for the Circuit Playground Express you get the best of both worlds, since it supports both simple block programming and the Arduino IDE, so maybe it's a gateway to C after all.

Viewpoint 2: Arduinos suck!

For me, the main reason why I'm not crazy about Arduino devices is the additional complexity of its programming languages. Compare the following sample programs, which all do the same exact thing – blink an LED once per second.

MakeCode:

CPX Javascript:

forever(function () {

    light.setPixelColor(0, 0xFF0000)

    pause(1000)

    light.setPixelColor(0, 0x000000)

    pause(1000)

})

CircuitPython for the CPX:

import board

import digitalio

import time

 

led = digitalio.DigitalInOut(board.D13)

led.direction = digitalio.Direction.OUTPUT

 

while True:

    led.value = True

    time.sleep(0.5)

    led.value = False

    time.sleep(0.5)

Arduino C:

void setup() {

 pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {

 digitalWrite(LED_BUILTIN, HIGH);

 delay(1000);

 digitalWrite(LED_BUILTIN, LOW);

 delay(1000);

}

You'll notice that the Python and C examples both require more code overhead, and are both rather terse and difficult to read unless you already know the languages in question. And that's the main thing for me.

When I'm building models, I don't want to spend a bunch of time learning or relearning complex computer languages. I don't want to try and figure out what operating system images I need to download onto my device just to make it boot. Or why the libraries are incompatible. I want to plug the thing in, and have lights start blinking.

I can program Arduinos – it's just not my favourite idea of spending my time. So for me the drawbacks of the educational devices are more than acceptable compared to their ease-of-use advantages. And frankly, the really modest requirements of most model making (a blinky light here, a random light there) don't need the full-on power of advanced computers!

Though if the more difficult languages weren't bad enough, the Arduino IDE (integrated development environment) is really crufty, shonky, and generally shaky. It's a mess. I find all the important functionality is hidden everywhere and I have to spend ages trying to remember where this thing is, or that thing. Code has a bunch of dependencies and everything breaks all the time, and the debugging tools are crap. It's all a huge time sink from my point of view.

But don't let me discourage you from exploring the tool if it works for you!

Useful links

https://www.evilmadscientist.com/2012/resistors-for-leds/

https://makecode.microbit.org/reference

http://tech.microbit.org/hardware/

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-circuit-playground-express.pdf

http://www.scalemodelanimation.com/Articles/Arduino_for_Modelers.pdf


The previous section

IV: Installing and using LEDs.