-2
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.

Gerben
  • 11,286
  • 3
  • 20
  • 34
Zivicium
  • 3
  • 1
  • 2
    Include your code in the post, not out on a link. After you paste the code into your post, select it and click the code icon (or press ctrl-K) to get code-formatting. In your post, tell us what is going wrong, not just that something is wrong. – James Waldby - jwpat7 Sep 05 '16 at 03:49
  • Are you saying there should be a 10ms delay between switching each coil on, or a 10ms after the previous coil is switched off before the next is turned on? You haven't said what the problem you are seeing is so I'm going to vote to close until you can explain the problem. – Code Gorilla Sep 06 '16 at 12:12

1 Answers1

2

I ran your code, and the problem seems to be the "var" you declare, which is not an Arduino type. Use int instead. Also if you have PINs 0 and 1 as output, Using the Serial might prove difficult.

    int coilSetOne = 0;
    int coilSetTwo = 1;
    int coilSetThree = 2;
    int coilSetFour = 3;
    int switchInput = 4;

    void setup()
    {
     // Serial.begin(9600);
      pinMode(coilSetOne, OUTPUT);
      pinMode(coilSetTwo, OUTPUT);
      pinMode(coilSetThree, OUTPUT);
      pinMode(coilSetFour, OUTPUT);
      pinMode(switchInput, INPUT);
    }

    void loop()
    {
      int switchMode = digitalRead(switchInput); //Use int
     /* Serial.print(digitalRead(switchInput));
      Serial.print(" ");
      Serial.print(digitalRead(switchInput) == HIGH);
      Serial.print(" ");*/

      if ( switchMode == HIGH ) {
        Serial.print("#Triggered");

        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);
      }
     // Serial.println();
    }

You didn't explain us the problem so I'm sorry if I missed the point.

sassoPera
  • 303
  • 1
  • 10