/*
-----------JTM Light Tower Latch switch----------------
created 2022
by JTM Technologies, inc.
<http://www.jtmtechnologies.com>
modified 7/8, 2022
by Lowell Dodge
Read digital input for tool active/idle and tool alarm
turn on/off 3 light tower lights, green-amber-red
-----Truth table-----
----conditions---- RED GREEN AMBER AUDIO
---------------------------------
(1) idle/no alarm | F F T F
(2) active/no alarm | F T F F
(3) Idle/alarm/audible | T F T T
(4) Idle/alarm/silent | T F T F
(5) Active/alarm/audible | T T F T
(6) Active/alarm/silent | T T F F
----------The circuit:--------------
* pcb uses a 24v relay activated by idle/active input from send indexer
* interface pin pin 20(adio-9 DO-1), the relay contacts are connected
* to arduino 5v and pin 9
*
* pcb uses 24v relay activated by system audible alarm adio 7 DO-14,
* the relay contacts are connected to arduino 5v and pin 10
*
* the 24V is connected to P1 pin 1 and P2 pin 7 which sends pwr to light
* tower yellow wire
*
* the AMBER led output is arduino pin 11 and drives a
* 5v relay which connects common to the light tower orange wire
*
* the GREEN led output is arduino pin 12 and drives a 5v relay which
* connects common to the light tower green wire
*
* the RED led output is arduino pin 5 and drives a 5v relay which
* connects common to the light tower red wire
*
* the AUDIO output is connectoed to arduino pin 6 and drives a 5v relay
* which connects common to the light tower purple wire (audio)
*
* the AUDIO silence button is connected to arduino pin 7 (input) which will
* silence the buzzer while alarm is active
*
*/
// constants that won't change. They're used here to set pin numbers:
const int alarmactive = 10; // the number of the alarm state pin
const int toolwentidle = 9; // the number of the idle state pin
const int amber = 11; // the number of the amber LED pin
const int green = 12; // the number of the green LED pin
const int red = 5; // the number of the red LED pin
const int audio = 6; // the number of the audible pin
const int silence = 7; // the number of the silence pin
// variables that will change:
int idlestatus = 0; // variable for active/idle status 1=idle
int alarmstatus = 0; // variable for alarm status 1=alarm
int silencestatus = 0; // variable for alarm silence status 1=silent
void setup() {
// initialize the LED pins as an outputs:
pinMode(green, OUTPUT);
pinMode(amber, OUTPUT);
pinMode(red, OUTPUT);
pinMode(audio, OUTPUT);
// initialize the idle,alarm, and silent pins as an input:
pinMode(toolwentidle, INPUT);
pinMode(alarmactive, INPUT);
pinMode(silence, INPUT);
}
void loop()
{
// read the state of the idle,alarm,and silence status values:
idlestatus = digitalRead(toolwentidle);
alarmstatus = digitalRead(alarmactive);
silencestatus = digitalRead(silence);
// check if the alarm status is true.
// if it is, alarmstatus is HIGH:
if (idlestatus == LOW)
{
// if tool is active
digitalWrite(green, HIGH);
digitalWrite(amber, LOW);
digitalWrite(red, LOW);
}
else if (idlestatus == HIGH)
{
// if tool is idle
digitalWrite(green, LOW);
digitalWrite(amber, HIGH);
digitalWrite(red, LOW);
}
if (silencestatus == LOW && alarmstatus == LOW)
{
// If no alarm, turn off red and audio
digitalWrite(red, LOW);
digitalWrite(audio, LOW);
}
else if (silencestatus == LOW && alarmstatus == HIGH)
{
// If alarm is true and silence button is not pressed
digitalWrite(red, HIGH);
digitalWrite(audio, HIGH);
delay(3000); // delay to sync red light w/sonalert
}
else if (silencestatus == HIGH && alarmstatus == HIGH)
{
// If alarm is true, and silence button is pressed
digitalWrite(red, HIGH);
digitalWrite(audio, LOW);
delay(3000); // delay to sync red light w/sonalert
}
}