Controlling a Solenoid with an Arduino

Hey Tim,

The problem would be that the Arduino is only capable of running one script at any given time. However with some clever scripting we can create a ‘clock signal’ each second and then every time it reaches the fifth second switch the solenoid valve. It would likely look something like this.

void setup(){
}

void Functiontotriggervalves() {
//Script to switch the valves
}

void Functiontotriggerlatch(){
//Script to trigger the latch
}

int t = 0;

void loop() {
delay(1000); //Wait one second
if (t==5){
Functiontotriggervalves(); //On the fifth second
t=0;
}
Functiontotriggerlatch();
t+=1;
}

Make sure to let us know how you go!

Bryce
Core Electronics | Support

1 Like