Barricade Lights v1.0
Project: Barricade Lights
One evening, I noticed that road repair had begun on part of a busy roadway. The construction company had placed barriers around the work area and flashing orange/yellow lights on the barricades were used to warn motorists of the activity.
The thing that caught my eye was the shifting patterns the barricade lights made. Each light would come on and go off roughly for the same duration as all the other lights but because of variations in activation time, battery power levels, timing circuitry and the like, the lights were rarely synchronized. As their on/off duration drifted, interesting blinking patterns were produced. These shifting patterns were probably much more noticeable to motorists so I assume the barricade lights were effective.
I decided to use Processing to recreate the essence of this visual experience and the source code for the Barricade_Lights project can be found on GitHub.
The timing algorithm for the software lights are based on the example Daniel Shiffman provides in his excellent book Learning Processing
The current code uses five individual lights that each have their own position, duration and color qualities. It would be easy to take this basic code and expanding it to include things like a large array of lights, random duration that drift over time and even use multiple colors that could possibly represent some external information.
Code Description:
- Variables for each of the five lights are defined.
- The setup routine sets the window properties, the starting state of the lights as well as a baseline for each light timer.
- Like many Processing programs, the draw routine runs in a continuous loop.
- First a duration check is gathered for the lights.
- Next each light has conditional statements to determine if the light's on/off duration has been met. If it has, the state of the light is toggled. If it is off, it is turned on, if on, it is turned off.
- - Off and On is achieved by drawing a yellow/orange filled circle to represent the On light or drawing a slightly larger black circle which effective erases the light, turning the light Off.
-- If the duration condition is met, the light is toggled and timer then reset.
-- If the duration condition is not met, the light remains in its current state.
With the condition check and shape drawing completed for each light, the draw routine loops.
Animation showing what the running program looks like:
Things to vary in the existing code:
* Position of the lights are set by their bNx and bNy variables.
For example, light 1 position is set by b1x, b1y.
* Light o/off time is set by its totalTimeN variable;
For example, light 1 duration is set by totalTime1. This time is in milliseconds.
* Light colors are set by the cN variables.
For example light 1 color is set by c1 = color(245,185,0) which
results in the typical orange/yellow light similar to actual barricade lights.
The Processing 3 code, available on my Digitalstew GitHub Page is simple and easily expandable to many other variations both useful and artistic and is freely released to the public domain, as-is,
with no restrictions.
UPDATE:
Version 2.0, found on the GitHub project page now includes A-Minor pentatonic clarinet music tones to the original barricade light code.
UPDATE:
Version 2.5 : Reduced lights to 4, changed notes to guitar G/D/E/C. Code and music note mp3 files are now on the GitHub project page.