Skip to toolbar
Titan Forge Cyberpunk March Diorama

Titan Forge Cyberpunk March Diorama

Supported by (Turn Off)

You might want to skip this post if you already have a headache

Tutoring 4
Skill 4
Idea 4
No Comments

So, having decided against going down the obvious “Back to the Future” path with a DeLorean in a cyberpunk setting, I had an idea about using it as a getaway car in my little diorama. I put it in a street scene with a couple of n’er-do-well looking types and set about adding LEDs to the headlights, tail lamps etc.

But the entire scene lacked something. There was a “story” there – but “two baddies getting a car out of the garage” wasn’t really screaming *excitement*. What I needed was some kind of tension or conflict.

So I decided to turn the car around, have it pointing “into” the scene, and have some armed police-types aiming at our protagonists. It was no longer a getaway car – but a police car, screeching to a halt at the scene, pinning our anti-heros into a corner in a city street.

Not only would it need light-up headlights, in which to trap the miscreants in its beam, but we’d have to have flashing sirens on the top as well – yet another excuse for even more LEDs. This was starting to look like a win-win.

It meant *lots* of LEDs.

Warning! Super-nerd content ahead.

You might want to skip this post if you already have a headache

The car alone was going to be like a christmas-tree with the number of lights on it: two white LEDs for the headlights, of course. Two red LEDs for the tail-lights/brake lights. I figured it’d be fun to add in some indicator LEDs on each corner – another four LEDs.

Then for the siren, we’d need at least two blue LEDs on the top flashing bar. Then, maybe as a nod to our American cousins (or maybe UK police also have them, I’ve never really studied that hard) I thought I’d stick a couple of red lights up there too, so the siren can alternate between red and blue flashing lights.

The obvious thing to do would be to wire all the LEDs and simply turn them on and off. But doing this creates a weird “pulsing” effect, depending on how many LEDs are lit up at any one time – as more LEDs are activated, the total current available is shared between them, so they all appear less bright; if some are turned off and a single LED is then switch on, that one LED appears much brighter with a more intense glow.

This kind of effect looks horrible – especially if the headlights go from dim to bright, for example, as the siren lights flash on and off.

What this called for was a MAX7219….

You might want to skip this post if you already have a headache

This little chip is a constant current LED driver. It can control up to 64 individual LEDs, and it ensures that every LED gets the same current, so there’s no pulsing of brightness as other lights turn on and off.

It’s usually used as an 8×8 LED matrix driver (and sometimes a 7-segment driver) and it works by lighting up just eight LEDs at a time (one row at a time). But it lights each individual row so quickly (at about 800 times a second) that you don’t see the flicker.

I have wired my LEDs so that they represent individual rows on a matrix (albeit with fewer than 8 “columns” in each “row). So, for example, I’ve put the four LEDs that make up the police siren lights on a single row. The indicator LEDs are on another row. The headlights on another, and the outside street lamps on yet another row.

So when I tell the microcontroller “turn on row zero, column two” what I’m actually saying is “switch on the third LED on the siren lights”. Similarly, when I send “turn off row two, column one” I’m effectively switching off one of the street lights. (counting in microcontroller land begins at zero – so the first “row” is zero, the second “row” is one, etc.)

Here’s a simple test rig, that lights up LEDs using a MAX7219; it cycles through every row, lighting up each individual column.

 

You might want to skip this post if you already have a headache

Now I’ve got my LEDs mounted onto a tiny homebrew PCB and I can see that they work with my MAX7219 controller chip, all that remains is to write the sequences to make them flash in the right order to create the appropriate animations…

Leave a Reply

Supported by (Turn Off)