int coilSetOne = 0;
int coilSetTwo = 1;
int coilSetThree = 2;
int coilSetFour = 3;
int switchInput = 4;
void setup()
{
pinMode(coilSetOne, OUTPUT);
pinMode(coilSetTwo, OUTPUT);
pinMode(coilSetThree, OUTPUT);
pinMode(coilSetFour, OUTPUT);
pinMode(switchInput, INPUT);
}
void loop()
{
var switchMode = digitalRead(switchInput)
if ( switchMode == HIGH ) {
digitalWrite(coilSetOne, HIGH);
delay(20);
digitalWrite(coilSetOne, LOW);
delay(10);
digitalWrite(coilSetTwo, HIGH);
delay(20);
digitalWrite(coilSetTwo, LOW);
delay(10);
digitalWrite(coilSetThree, HIGH);
delay(20);
digitalWrite(coilSetThree, LOW);
delay(10);
digitalWrite(coilSetFour, HIGH);
delay(20);
digitalWrite(coilSetFour, LOW);
}}
If the arduino detects that the switch is powered, it should power the coils. They should stay on for 20m and the delay between coils turning on should be 10ms.