The circuit is designed to control a series of solenoid valves using an Arduino UNO microcontroller. The circuit includes a power supply section that converts 240V AC to a lower voltage suitable for the Arduino and the relays. It features a manual override switch for local control and a set of relays to control the solenoid valves. The Arduino is programmed to operate the valves either in a local control mode or based on serial commands for remote operation.
// Arduino UNO Code
const int solenoidValves[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // Relay control pins
const int localControlPin = 12; // Local control switch pin
const unsigned long timerDuration = 5000; // 5 seconds in milliseconds
bool localControl = false;
int startValve = 0; // 0 for valve 1, 1 for valve 2, 2 for valve 3, etc.
void setup() {
Serial.begin(9600); // Start serial communication for DCS signals
pinMode(localControlPin, INPUT_PULLUP); // Local control switch with pull-up resistor
for (int i = 0; i < 10; i++) {
pinMode(solenoidValves[i], OUTPUT);
digitalWrite(solenoidValves[i], LOW); // Ensure valves are off initially
}
}
void loop() {
if (digitalRead(localControlPin) == LOW) {
localControl = !localControl; // Toggle local control mode
delay(200); // Debounce delay
}
if (localControl) {
// Local control logic
// Implement the logic for local control here
// For example, you might want to manually turn on/off valves
} else {
// Remote control logic
if (Serial.available() > 0) {
char command = Serial.read();
if (command == '2') {
startValve = 1; // Start from solenoid valve number 2
} else if (command == '3') {
startValve = 2; // Start from solenoid valve number 3
}
}
// Operate the solenoid valves with a 5-second delay between each
for (int i = startValve; i < startValve + 10; i++) {
int valveIndex = i % 10; // Wrap around to the beginning of the array
digitalWrite(solenoidValves[valveIndex], HIGH); // Turn on valve
delay(timerDuration); // Wait for 5 seconds
digitalWrite(solenoidValves[valveIndex], LOW); // Turn off valve
}
}
}
This code is designed to control a series of solenoid valves using an Arduino UNO. It includes a local control mode that can be toggled via a switch and a remote control mode that operates based on serial commands. The valves are operated with a 5-second delay between each, and the starting valve can be adjusted via serial commands.