Hand-Off-Auto selector with a panel meter
Read a three-position HAND-OFF-AUTO selector switch through optocouplers, drive a 24 V pilot light through an SSR, and watch its voltage on a panel meter.
Industrial · Intermediate
In a real product: Pump control panel (Industrial): A selector chooses manual, off or automatic control of a plant pump.
Every control panel door has a HAND-OFF-AUTO switch. In HAND the operator runs the machine directly, in OFF it is stopped, and in AUTO the controller decides. This project reads one with an Arduino and drives a lamp according to the mode.
What you'll learn
- How a selector switch exposes its position as two contacts: 13-14 (I, left) and 23-24 (II, right); neither means 0
- Reading two 24 V contacts with an optocoupler module, as active LOW inputs
- Turning a three-state input into a mode in code
- Switching a 24 V lamp from a pin with a solid-state relay, and watching it with a panel voltmeter
How it works
24 V goes to the selector's common terminals 13 and 23. Position I (HAND) joins 13-14 and reaches optocoupler IN1; position II (AUTO) joins 23-24 and reaches IN2; the centre 0 (OFF) joins neither. The module's OUT1 and OUT2 read LOW when their input has 24 V.
The sketch turns that into a mode. HAND lights the lamp steadily, OFF keeps it dark, and in AUTO the controller blinks it once a second, as a program would run a machine. The lamp is switched by an SSR, and the panel voltmeter across the lamp shows 24 V when it is on and 0 V when it is off.
Try this
- Click the knob to step through the three positions and watch the serial monitor.
- Change the selector to a 2-position switch in its settings: there is no OFF now.
- Add a stack light and light its green tier only in AUTO.
sketch.ino
// HAND-OFF-AUTO: a selector switch's two contacts through an optocoupler module choose how the lamp behaves.
const int HAND_IN = 2; // optocoupler OUT1: LOW in position I (HAND)
const int AUTO_IN = 3; // optocoupler OUT2: LOW in position II (AUTO)
const int LAMP = 8; // SSR input: HIGH lights the 24 V lamp
enum Mode { MODE_OFF, MODE_HAND, MODE_AUTO };
Mode last = MODE_OFF;
Mode readMode() {
if (digitalRead(HAND_IN) == LOW) return MODE_HAND;
if (digitalRead(AUTO_IN) == LOW) return MODE_AUTO;
return MODE_OFF;
}
void setup() {
Serial.begin(9600);
pinMode(HAND_IN, INPUT);
pinMode(AUTO_IN, INPUT);
pinMode(LAMP, OUTPUT);
}
void loop() {
Mode mode = readMode();
if (mode != last) {
Serial.println(mode == MODE_HAND ? "HAND: lamp on" : mode == MODE_AUTO ? "AUTO: lamp blinks" : "OFF: lamp off");
last = mode;
}
if (mode == MODE_HAND) {
digitalWrite(LAMP, HIGH);
} else if (mode == MODE_AUTO) {
digitalWrite(LAMP, (millis() / 1000) % 2 == 0); // the "program" runs the machine
} else {
digitalWrite(LAMP, LOW);
}
}