Bringing The Quake Flicker To Life With A Hacked Light

If you ever feel a pang of shame because you’ve been reusing the same snippets of code in your projects for years, don’t. Even the big names do it, as evidenced by the fact that code written to govern flickering lights back in 1996 for Quake is still being used in AAA titles like 2020’s Half-Life: Alyx. In honor of this iconic example of digital buck-passing, [Rodrigo Feliciano] thought he’d port the code in question over to the Arduino and recreate the effect in real-life.

Since the Quake engine has been released under the GPLv2, it’s easy to pull up the relevant section of the code to see how the lighting was configured. Interestingly, lighting patterns were implemented as strings, where the letters from a to z referenced how bright the light should appear. So for example, a strobe light that goes between minimum and maximum brightness would be written as “aaaaaaaazzzzzzzz”, while a flickering light could be represented with the string nmonqnmomnmomomno“.

An emergency light provided the LEDs and enclosure.

This ended up being very easy to implement on the Arduino in just a few lines, as [Rodrigo] simply had to assign each letter in the string a numerical value between 0 and 255 using map, and then use the resulting number to set the LED brightness with analogWrite.

With the code written, [Rodrigo] then had to put the hardware together. He stripped down a basic emergency light to get an array of white LEDs and a handy enclosure. He also wired up a simple transistor circuit on a scrap of perfboard so the Arduino Pro Mini could control all the LEDs from a single GPIO pin. Combined with a long USB cable to power it, and he’s got a perfect desk accessory for late-night gaming sessions.

In the video below you can see the final result, which [Rodrigo] has even synced up to footage from the classic 1996 shooter. The light makes for an interesting conversation piece, but we think the logical next step is to work this technique into an ambilight-like system to really make it feel like you’re wandering down those dimly lit corridors.

14 thoughts on “Bringing The Quake Flicker To Life With A Hacked Light

    1. I mean, if it’s GOOD code, then sure keep using it.

      But if you’re using the same old janky code for years just because you can’t be bothered to update it, then that’s a problem. One would hope your skills are improving with time, so if there’s really no difference in your style or efficiency in 10 years…

  1. Just in time for Halloween. This’ll save me some work. I’m going to add a button to cycle styles though because that sounds easier than reflashing each time I might want to change it.

    Also, since it uses text, I may have to see what various curse words look like in flicker.

  2. That good old bad fluorescent lamp flicker is going extict.
    LEDs have completely other failure modes.
    I wonder what future horror movies will use.
    I always cringe when todays horror movies/games use the beam of an old incandescent flashlight.
    Honestly, guys? Even my humble key chain light has 1000 Lumens. And that’s not even the brightest one.

    1. I’ve seen LED streetlights which look like they’re trying to be disco strobes or send morse code. It’s a shame how much material goes into these things in the name of saving energy when they don’t last very long.
      The best outdoor lighting solution is none at all, but second to that is the fluorescent induction lamp. There’s nothing to wear other than the phosphor (which should last 20 years or more if not overdriven), and it doesn’t require a giant heat sink.

  3. > [Rodrigo] simply had to assign each letter in the string a numerical value between 0 and 255 using map

    Hm, why not just use the ASCII code of the letter, subtract the ASCII code for ‘a’ and multiply by 256/26?

  4. I know Arduinos are cheap these days, and would give you more control if you actually want that control… but that’s the long way around the barn.

    The traditional way to create an erratically flickering light effect was just a fluorescent starter. Starters were traditionally just a thermostat and a neon bulb in series; the bulb would heat the thermostat, it would turn off, the system would cool, and this on/off behavior run through an inductor provided the surge needed to initially ionize the gas in the tube, repeating until (and after) the arc caught. Putting that erratically-repeating cycle in series with an incandescent bulb instead produced a nice irregular flicker; the hysteresis as the bulb warmed up and cooled off would cause each flash to vary in brightness too. The result looked very much like what you’d expect from a loose connection (without the hazards thereof); you could get some control of the rate and brightness by picking the bulb wattage and/or putting it on a dimmer.

    If you’ve seen a flickering light in a haunted house or on stage, this is probably how they built it.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.