Starting Lights by Juan Pardo
It is an Arduino based system. You will find below details for building the device provided by the Author.
Mounting the device
Code
//==============================================================================
// Program: ZRound.ino
// Author: Juan Pardo
// Target: UNO R3, IDE 1.0.5
// Date: 2013/08/12
// Time: 02:32
// Notes:
// Uses Serial I/O
// Reference:
//==============================================================================
#define VERSION 0.7
//=====[ INCLUDE ]==============================================================
//=====[ CONSTANTS ]============================================================
#define CMD_START "$START"
#define CMD_STOP "$STOP"
#define ANS_GO "$GO"
#define bSize 64
#define L_OFF HIGH
#define L_ON LOW
//=====[ PINS ]=================================================================
int DebugLed = 13;
//=====[ VARIABLES ]============================================================
char Buffer[bSize]; // Serial buffer
char ShadowBuffer[bSize]; // Serial buffer
char Command[10];
byte LightPort[]={4,5,6,7,8,9}; // Last port will be used as green light
byte LIGHTS;
byte GREENLIGHT;
//=====[ ReadSerialCommand ]====================================================
int ReadSerialCommand(void) {
int BytesCount = -1;
BytesCount = Serial.readBytesUntil('\n',Buffer,bSize-1);
if (BytesCount > 0) {
Buffer[BytesCount]='\0';
}
else{
Buffer[0]='\0';
}
return BytesCount;
}
//=====[ LightsOFF ]=============================================================
void LightsOFF(void) {
for(int i=0;i<LIGHTS;i++){
digitalWrite(LightPort[i], L_OFF); //Switch off lights
}
}
//=====[ SETUP ]===============================================================
void setup() {
LIGHTS = sizeof(LightPort);
GREENLIGHT = LIGHTS-1;
for(int i=0;i<LIGHTS;i++){
pinMode(LightPort[i], OUTPUT ); //Setup lights ports
digitalWrite(LightPort[i], L_OFF); //Switch off lights
}
Serial.begin(9600);
// Switchoff lights
LightsOFF();
}
//=====[ LOOP ]===============================================================
void loop() {
if(ReadSerialCommand()>0){
strcpy(ShadowBuffer,Buffer);
strcpy(Command,strtok(ShadowBuffer,","));
if(strcmp(Command, CMD_START)==0){
LightsOFF();
for(int i=0;i<LIGHTS-1;i++){
digitalWrite(LightPort[i], L_ON); //Switch on lights
delay(1000);
}
// Send GO to PC
Serial.print(ANS_GO);
Serial.print('\n');
Serial.flush();
LightsOFF();
digitalWrite(LightPort[GREENLIGHT], L_ON); //Switch on Green light
}
else{
if(strcmp(Command, CMD_STOP)==0){
LightsOFF();
// Red lights blinking during 1 minute
for(int i=0;i<60;i++){
for(int j=0;j<LIGHTS-1;j++){
digitalWrite(LightPort[j], L_ON);
}
delay(500);
for(int j=0;j<LIGHTS-1;j++){
digitalWrite(LightPort[j], L_OFF);
}
delay(500);
}
LightsOFF();
}
}
}
}


