22 lines
462 B
C++
22 lines
462 B
C++
int buttonPin = D9;
|
|
int Led = A4;
|
|
int buttonState;
|
|
// the setup function runs once when you press reset or power the board
|
|
void setup() {
|
|
// initialize digital pin LED_BUILTIN as an output.
|
|
pinMode(Led, OUTPUT);
|
|
pinMode(buttonPin, INPUT);
|
|
}
|
|
|
|
// the loop function runs over and over again forever
|
|
void loop() {
|
|
buttonState = digitalRead(buttonPin);
|
|
if (buttonState == LOW) {
|
|
digitalWrite(Led, HIGH);
|
|
|
|
} else {
|
|
digitalWrite(Led, LOW);
|
|
}
|
|
|
|
}
|