21 lines
311 B
Arduino
21 lines
311 B
Arduino
|
|
||
|
const int buttonPin = 12;
|
||
|
const int ledPin = 13;
|
||
|
|
||
|
int buttonState = 0;
|
||
|
|
||
|
void setup() {
|
||
|
pinMode(ledPin, OUTPUT);
|
||
|
pinMode(buttonPin, INPUT);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
buttonState = digitalRead(buttonPin);
|
||
|
|
||
|
if (buttonState == HIGH) {
|
||
|
digitalWrite(ledPin, HIGH);
|
||
|
} else {
|
||
|
digitalWrite(ledPin, LOW);
|
||
|
}
|
||
|
}
|