Third week homework

This week, i really enjoy the homework. I tried several ways to write code to write the same effect. Although,  it isn’t work all the time. So interesting~

home 3:

int buttonpin =9;
int buttonpin1 =10;
int ledpin =12;
int buttonState = 0;
int buttonState2 = 0;

void setup() {
pinMode(ledpin, OUTPUT);
pinMode(buttonpin,INPUT_PULLUP);
pinMode(buttonpin1,INPUT_PULLUP);
Serial.begin(9600);
}

void loop() {
buttonState = digitalRead(buttonpin);
buttonState2 = digitalRead(buttonpin1);
if (buttonState == LOW){
digitalWrite(ledpin,LOW);
}else if(buttonState2 == LOW){
digitalWrite(ledpin,HIGH);
}
}

One thought on “Third week homework”

  1. Nice job on the code, Leng! Next time please be sure to upload your videos to a sharing site first, then embed them here in the blog. Please do not upload video files directly to the blog, as the files are too big. Thank you! =D

    Like

Comments are closed.