Nissan Fog Lamp: Arduino Firmware

The upcycled Nissan fog lamp now has a desk stand:

Nissan Fog Lamp - table mount
Nissan Fog Lamp – table mount

A knockoff Arduino Pro Mini atop a strip of foam tape drives the WS2812 RGB LEDs:

Nissan Fog Lamp - table mount interior
Nissan Fog Lamp – table mount interior

Next time, I’ll cut the wires another inch longer.

The firmware is a tidied-up version of the vacuum tube code, minus cruft, plus fixes, and generally better at doing what it does. The Pro Mini lacks a USB output, so this came from the same code running on a Nano:

14:44:04.169 -> Algorithmic Art
14:44:04.169 ->  RGB WS2812
14:44:04.169 -> Ed Nisley - KE4ZNU - April 2020
14:44:04.169 -> Lamp test: flash full-on colors
14:44:04.169 ->  color: 00ff0000
14:44:05.165 ->  color: 0000ff00
14:44:06.160 ->  color: 000000ff
14:44:07.155 ->  color: 00ffffff
14:44:08.151 ->  color: 00000000
14:44:09.180 -> Random seed: da98f7f6
14:44:09.180 -> Primes: 7 19 3
14:44:09.180 ->  Super cycle length: 199500 steps
14:44:09.180 -> Inter-pixel phase: 1 deg = 26 steps
14:44:09.180 ->  c: 0 Steps:  3500 Init:  1538 Phase:   2 deg PWM: 255
14:44:09.180 ->  c: 1 Steps:  9500 Init:  7623 Phase:   0 deg PWM: 255
14:44:09.213 ->  c: 2 Steps:  1500 Init:  1299 Phase:   6 deg PWM: 255
14:44:19.265 -> Color 2     steps 1500  at 15101    ms 50       TS 201     
14:45:34.293 -> Color 2     steps 1500  at 90136    ms 50       TS 1701    
14:45:43.085 -> Color 1     steps 9500  at 98940    ms 50       TS 1877    
14:45:47.332 -> Color 0     steps 3500  at 103192   ms 50       TS 1962    
14:46:49.324 -> Color 2     steps 1500  at 165170   ms 50       TS 3201  
… much snippage …
17:26:52.896 -> Color 2     steps 1500  at 9769584  ms 50       TS 195201  
17:28:07.926 -> Color 2     steps 1500  at 9844618  ms 50       TS 196701  
17:29:11.000 -> Color 0     steps 3500  at 9907697  ms 50       TS 197962  
17:29:22.974 -> Color 2     steps 1500  at 9919653  ms 50       TS 198201  
17:30:27.941 -> Supercycle end, setting new color values
17:30:27.941 -> Primes: 17 7 3
17:30:27.941 ->  Super cycle length: 178500 steps
17:30:27.941 -> Inter-pixel phase: 1 deg = 23 steps
17:30:27.941 ->  c: 0 Steps:  8500 Init:  5415 Phase:   0 deg PWM: 255
17:30:27.974 ->  c: 1 Steps:  3500 Init:  3131 Phase:   2 deg PWM: 255
17:30:27.974 ->  c: 2 Steps:  1500 Init:   420 Phase:   5 deg PWM: 255
17:30:46.394 -> Color 1     steps 3500  at 10003091 ms 50       TS 369     
17:31:21.964 -> Color 2     steps 1500  at 10038658 ms 50       TS 1080  

The “Super cycle length” is the number of 50 ms steps until the colors start repeating, something over an hour in that sample. When the code reaches the end of the supercycle, it picks another set of three prime numbers, reinitializes the color settings, and away it goes.

The fog light looks pretty in action:

Nissan Fog Lamp - blue phase
Nissan Fog Lamp – blue phase

The four LEDs don’t produce the same light pattern as the halogen filament and they’re distinctly visible when you squint against the glare:

Nissan Fog Lamp - reflector LED detail
Nissan Fog Lamp – reflector LED detail

The shadow on the right comes from the larger hood support strut, the shadow on the left is the narrower strut, and the two other gaps show the beam angle gaps between the LEDs.

You’ll see plenty of residual sandpaper scratches on the lens: my surface (re)finishing hand is weak.

The LED beamwidth is so broad the “bulb” position inside the reflector doesn’t make much difference, particularly as it must, at most, wash a wall and ceiling at close range:

Nissan Fog Lamp - wall wash light
Nissan Fog Lamp – wall wash light

All in all, a much-needed dose of Quality Shop Time.

The Arduino source code as a GitHub Gist:

5 thoughts on “Nissan Fog Lamp: Arduino Firmware

    1. It’s on temporary loan across the intersection as a service bay nightlight.

      Similar to a head on a stake at the village gate: “Don’t drive like this!”

Spam comments get trashed, so don't bother. Comment moderation may cause a delay.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s