Skip to main content
Changed mills() to millis() and added a comma.
Source Link
VE7JRO
  • 2.5k
  • 19
  • 26
  • 29

You should be using digitalRead(8) instead of digitalWrite(8, HIGH). Your sketch is also missing some curly brackets.

void setup(){
  pinMode(4, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, INPUT);
}

void loop(){
  if(digitalRead(8) == HIGH){
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
  } 
  else{
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }
  digitalWrite(4,HIGH);
  delay(1500);
  digitalWrite(4,LOW);
}

The use of delay() will block the sketch from doing anything else, and should be replaced with a millsmillis() timer. Have a look at the BlinkWithoutDelay example in the IDE.

You should be using digitalRead(8) instead of digitalWrite(8, HIGH). Your sketch is also missing some curly brackets.

void setup(){
  pinMode(4, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, INPUT);
}

void loop(){
  if(digitalRead(8) == HIGH){
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
  } 
  else{
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }
  digitalWrite(4,HIGH);
  delay(1500);
  digitalWrite(4,LOW);
}

The use of delay() will block the sketch from doing anything else and should be replaced with a mills() timer. Have a look at the BlinkWithoutDelay example in the IDE.

You should be using digitalRead(8) instead of digitalWrite(8, HIGH). Your sketch is also missing some curly brackets.

void setup(){
  pinMode(4, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, INPUT);
}

void loop(){
  if(digitalRead(8) == HIGH){
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
  } 
  else{
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }
  digitalWrite(4,HIGH);
  delay(1500);
  digitalWrite(4,LOW);
}

The use of delay() will block the sketch from doing anything else, and should be replaced with a millis() timer. Have a look at the BlinkWithoutDelay example in the IDE.

Source Link
VE7JRO
  • 2.5k
  • 19
  • 26
  • 29

You should be using digitalRead(8) instead of digitalWrite(8, HIGH). Your sketch is also missing some curly brackets.

void setup(){
  pinMode(4, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, INPUT);
}

void loop(){
  if(digitalRead(8) == HIGH){
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
  } 
  else{
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }
  digitalWrite(4,HIGH);
  delay(1500);
  digitalWrite(4,LOW);
}

The use of delay() will block the sketch from doing anything else and should be replaced with a mills() timer. Have a look at the BlinkWithoutDelay example in the IDE.