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“.

<img data-attachment-id="496921" data-permalink="https://hackaday.com/2021/09/21/bringing-the-quake-flicker-to-life-with-a-hacked-light/quakelight_detail/" data-orig-file="https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg" data-orig-size="1135,645" data-comments-opened="1" data-image-meta='{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0"}' data-image-title="quakelight_detail" data-image-description="" data-image-caption="

An emergency light provided the LEDs and enclosure.

” data-medium-file=”https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?w=400″ data-large-file=”https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?w=800″ loading=”lazy” src=”https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?w=400″ alt=”” width=”400″ height=”227″ srcset=”https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg 1135w, https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?resize=250,142 250w, https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?resize=400,227 400w, https://hackaday.com/wp-content/uploads/2021/09/quakelight_detail.jpg?resize=800,455 800w” sizes=”(max-width: 400px) 100vw, 400px”>

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.

…read more

Source:: Hackaday