Site icon Making Studio

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);
}
}

Exit mobile version