Wiring Code Example

Wiring code example
Wiring 
Wiring is a derivative of C/C++ and is a coding language designed for micro-controller applications. Below is an example of Wiring code.
int switchState = 0;
int x = 0;
void setup(){
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(2, INPUT);
}
void loop(){
  switchState = digitalRead(2);
  if (switchState == 0 && x == 0){
    switchLow();
  }  
  else if (switchState == 0 && x == 4){
    flasHera();
  }  
else if (switchState == 1){
    switchHigh();
  } 
  
  while (switchState == 1) {switchState = digitalRead(2);;delay(50); 
    
}
}
void switchLow(){
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    
  }  

void switchHigh(){x ++; delay(50);
  if (x == 1){
      digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
       
  }
  else if (x == 2){
      digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);   
    
  }
  else if (x == 3){
      digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
    
  }
  else if (x == 4){ flasHerb();
  }
      

 else if (x > 4){
      digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    x = 0;}
 
}

void flasHera(){
  digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(100);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(100);
}

void flasHerb(){while (switchState == 1) {  
  digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(100);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(100);
    switchState = digitalRead(2);
}
}