Digital Electronics Lab Report Week 2

BY BENNA SU

PART1.

PART 2

PART 3

PART 4

PART 5

PART 6

I try to get through all of this and I think I got them all working.

This Is my Code

int LedRedPin = 7;
int LedYellowPin = 8;
int LedBluePin = 9;
int LedGreenPin = 10;
int Button1 = 33;
int Button2 = 34;
int Switch = 35;
int Button3 = 36;
int Potentiometer = 32;



void setup() {
  pinMode(LedRedPin, OUTPUT);
  pinMode(LedYellowPin, OUTPUT);
  pinMode(LedBluePin, OUTPUT);
  pinMode(LedGreenPin, OUTPUT);
  pinMode(Button1, INPUT);
  pinMode(Button2, INPUT);
  pinMode(Button3, INPUT);
  pinMode(Switch, INPUT);
  pinMode(Potentiometer, INPUT);
 
  
  
}

void loop() {

  if(digitalRead(Button1) == HIGH) {
    digitalWrite(LedRedPin, HIGH);
    digitalWrite(LedYellowPin, HIGH);
    digitalWrite(LedBluePin, HIGH);
    digitalWrite(LedGreenPin, HIGH);
    delay(500);
    digitalWrite(LedRedPin, LOW);
    digitalWrite(LedYellowPin, LOW);
    digitalWrite(LedBluePin, LOW);
    digitalWrite(LedGreenPin, LOW);
    delay(500);
  }
  if(digitalRead(Button2) == HIGH) {
    digitalWrite(LedGreenPin, HIGH);
    delay(2000);
    digitalWrite(LedGreenPin, LOW);
    delay(2000);
    digitalWrite(LedBluePin, HIGH);
    delay(1500);
    digitalWrite(LedBluePin, LOW);
    delay(1500);
    digitalWrite(LedYellowPin, HIGH);
    delay(1000);
    digitalWrite(LedYellowPin, LOW);
    delay(1000);
    digitalWrite(LedRedPin, HIGH);
    delay(500);
    digitalWrite(LedRedPin, LOW);
    delay(500);
    
  }
  if(digitalRead(Switch) == HIGH) {
    digitalWrite(LedRedPin, HIGH);
    delay(2000);
    digitalWrite(LedRedPin, LOW);
    delay(2000);
    digitalWrite(LedYellowPin, HIGH);
    delay(1500);
    digitalWrite(LedYellowPin, LOW);
    delay(1500);
    digitalWrite(LedBluePin, HIGH);
    delay(1000);
    digitalWrite(LedBluePin, LOW);
    delay(1000);
    digitalWrite(LedGreenPin, HIGH);
    delay(500);
    digitalWrite(LedGreenPin, LOW);
    delay(500);
  }
  if(digitalRead(Button3) == HIGH) {
    digitalWrite(LedRedPin, HIGH);
    delay(1000);
    digitalWrite(LedRedPin, LOW);
    delay(2000);
    digitalWrite(LedYellowPin, HIGH);
    delay(1000);
    digitalWrite(LedYellowPin, LOW);
    delay(1500);
    digitalWrite(LedBluePin, HIGH);
    delay(1000);
    digitalWrite(LedBluePin, LOW);
    delay(1000);
    digitalWrite(LedGreenPin, HIGH);
    delay(1000);
    digitalWrite(LedGreenPin, LOW);
    delay(500);
    
  }
  // put your main code here, to run repeatedly:

}

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始