Introduction: Safety Stoplight: the Easy, Arduino-powered, Voltage Warning Light

This was a side project I completed during my time as Summer Undergraduate Laboratory Intern at the National Renewable Energy Lab. I highly recommend the program. (I did much cooler things than this, but those will be papers not Instructables :)

We worked with some occasionally high voltage equipment that required handling from time to time. We built the stoplight as a way of tracking the voltage and staying out of the way when the system was hot.

Perhaps the best  we had was to idea have all three lights flash when there was no signal at all. That way you're not deceived by disconnected cables.



I suppose this project owes big debt of inspiration to mkanoap's network stoplight though this project differs in the simplicity of the components used in the assembly. Thanks to the friendly components of Mouser electronics Arduino Tinker kit, it was built with almost no soldering.

Bill of Materials:
Chinese Stoplight
Replacement lamps  (optional, if you want to get rid of the blinking, we used pricey LED ones so we didn't have heat issues)
Arduino Uno
TinkerKit Sensor Shield
TinkerKit Relay Module x 3 (one for each light)
DC Power Supply (we used a RS-15-15 which we dialed down to 12V)
Some small screws for mounting components (optional)
Small protoboard
A couple resistors (depends on application)
Wire

Step 1: The Guts



The lights that come standard blinked and so we replaced them with cool (i.e. not hot) LED lamps.

I don't suppose I need to go much through the wiring. It should be pretty straight forward

Step 2: Code and Voltage Divider

The critical thing to do is wire a voltage divider so that your maximum voltage going to the analog input pin will be 5 volts ("500" in the attached code).

You'll need the Timer library to run the code I've written

#include <Event.h>
#include <Timer.h>


const int analogInPin = A0;  // Analog input pin
const int Red =    ;// pin numbercorresponding to Mouser output where you plugged in the light
const int Yellow =    ;// pin corresponding to Mouser output where you plugged in the light
const int Greeen =    ;// pin corresponding to Mouser output where you plugged in the light
const int HighThreshold =    ;// set the voltage value (x10) you want to trigger the red light here
const int MediumThreshold =   ;// set the voltage value (x10) you want to trigger the yellow light here
const int LowThreshold =   ;// set the voltage value (x10) you want to trigger the green light
                            //anything below the low threshold will cause the system to flash
const int PeakVoltage =  //the highest voltage (x10) you anticipate (used to map arduino signal to corresponding voltages  (though the arduino will only sense 5 volts because of the voltage divider)                          

Timer t;

int sensorValue = 0;        // value read from the pot
int outputValue = 0;
int loopcount;
void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  loopcount = 0;
  pinMode(Red, OUTPUT);
  pinMode(Yellow, OUTPUT);
  pinMode(Green, OUTPUT);

}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);           
  // map it to the range of the analog out:

  outputValue = map(sensorValue, 0, 1023, 0, PeakVoltage); 
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);  

  if (outputValue >= HighThreshold)
    {
      digitalWrite(Red,HIGH);
      digitalWrite(Yellow,LOW);
      digitalWrite(Green, LOW);
      t.stop(flashYellow);
    } 
  else if  (outputValue < HighThreshold && outputValue > MediumThreshold)
   {
      digitalWrite(Red,LOW);
      digitalWrite(Yellow,HIGH);
      digitalWrite(Green, LOW);
      t.stop(flashYellow);
    } 
  else if  (outputValue < MediumThreshold && outputValue > LowThreshold)
   {
      digitalWrite(Red,LOW);
      digitalWrite(Yellow,LOW);
      digitalWrite(Green, HIGH);
      t.stop(flashYellow);
    } 
   else if  (outputValue <= LowThreshold)
   {
     flashYellow = t.oscillate(Yellow,500,HIGH);
    }  




  if ((oldValue > 0) && (outputValue < (oldValue*(1-Sensitivity)))
      {

      }

  // print the results to computer the every (first argument) miliseconds
  t.every(100, reportData);

t.update();
}

void reportData()
{
  Serial.println(outputValue);
}

Step 3: Go Forth and Build

Let me know if you have any questions about the stoplight.

Be sure to check out my Personal Website for more projects.

LED Contest with Elemental LED

Participated in the
LED Contest with Elemental LED