You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
505 B
20 lines
505 B
const int buttonPin = 2; // the number of the pushbutton pin
|
|
const int ledPin = 13; // the number of the LED pin
|
|
|
|
void setup() {
|
|
// initialize the LED pin as an output:
|
|
pinMode(ledPin, OUTPUT);
|
|
// initialize the pushbutton pin as an input:
|
|
pinMode(buttonPin, INPUT);
|
|
digitalWrite(buttonPin, HIGH);
|
|
}
|
|
|
|
void loop(){
|
|
int buttonState = digitalRead(buttonPin);
|
|
if (buttonState == LOW) {
|
|
digitalWrite(ledPin, HIGH);
|
|
}
|
|
else {
|
|
digitalWrite(ledPin, LOW);
|
|
}
|
|
}
|