Files
PlatformIO_GarageDoorMonitor/src/main.cpp

24 lines
543 B
C++
Raw Normal View History

2022-06-16 17:18:09 -05:00
#include <Arduino.h>
const int buttonPin = 4; // Reed switch - don't forget the pull down resistor.
const int ledPin = 2; // Internal LED
void setup() {
Serial.begin(9600);
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
delay(500);
}