Arduino + Pushbutton


Arduino Code

int buttonPin = 3;
int buttonState = 0;

void setup(){
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}

void loop(){
buttonState = digitalRead(buttonPin);
switch(buttonState){
case HIGH:
Serial.println("off");
break;
case LOW:
Serial.println("on");
break;
}
delay(100);
}

No comments:

Post a Comment