int potValue = 0;
int led1Pin = 7;
int led2Pin = 8;
int led3Pin = 9;
int led4Pin = 10;
int button1Pin = 33;
int button2Pin = 34;
int button3Pin = 36;
int switchPin = 35;

int delayLength = 200;
int randomNumber = 1;

void setup() {
  Serial.begin(9600);

  for (int i = 0; i < 4; i++) {

    pinMode(i+7, OUTPUT);
    
  }

  for (int i = 0; i < 4; i++) {

    pinMode(i+33, INPUT);
    
  }
  
}

void loop() {

  delayLength = analogRead(A13);

  if(digitalRead(button1Pin) == HIGH) {

      for (int i = 0; i < 4; i++) {

              digitalWrite(i+7, HIGH);
    
       }

      delay(delayLength);

      for (int i = 0; i < 4; i++) {

              digitalWrite(i+7, LOW);
    
       }
      
      delay(delayLength);
    
  } else if(digitalRead(button2Pin) == HIGH) {
    
      if(digitalRead(switchPin) == HIGH) {

          for (int i = 0; i < 4; i++) {

              digitalWrite(i+7, HIGH);
              delay(delayLength);
              digitalWrite(i+7, LOW);
    
          }
          
      } else {

          for (int i = 3; i >=0; i--) {

              digitalWrite(i+7, HIGH);
              delay(delayLength);
              digitalWrite(i+7, LOW);
    
          }
        
      }

  } else if (digitalRead(button3Pin) == HIGH) {

      randomNumber = random(1, 5);
      if (randomNumber == 4) {

          digitalWrite(led4Pin, HIGH);
          delay(delayLength);
          digitalWrite(led4Pin, LOW);
        
      } else if (randomNumber == 3) {

          digitalWrite(led3Pin, HIGH);
          delay(delayLength);
          digitalWrite(led3Pin, LOW);
        
      } else if (randomNumber == 2) {

          digitalWrite(led2Pin, HIGH);
          delay(delayLength);
          digitalWrite(led2Pin, LOW);
        
      } else if (randomNumber == 1) {

          digitalWrite(led1Pin, HIGH);
          delay(delayLength);
          digitalWrite(led1Pin, LOW);
        
      }
      
  }
  
//  potValue = analogRead(A13);
//  Serial.println(potValue);
//  delay(100);
}


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.