From 115805ddc14530144148918ea85c13b55a94f745 Mon Sep 17 00:00:00 2001 From: Tilman Date: Sun, 24 Feb 2019 13:31:15 +0000 Subject: [PATCH] Garage.ino --- garage/Garage.ino | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 garage/Garage.ino diff --git a/garage/Garage.ino b/garage/Garage.ino new file mode 100644 index 0000000..7bffa7d --- /dev/null +++ b/garage/Garage.ino @@ -0,0 +1,33 @@ +const int remotePin = D1; +const int buttonPin = D2; +const int motorPin = D3; + +void setup() { + Serial.begin(9600); + Serial.println("Start"); + pinMode(BUILTIN_LED, OUTPUT); + pinMode(remotePin, OUTPUT); + pinMode(buttonPin, INPUT); + pinMode(motorPin, OUTPUT); +} + + +int buttonState = 0; + +void loop() { + buttonState = digitalRead(buttonPin); + //Serial.println(buttonState); + + if (buttonState == HIGH) { + Serial.println("Button pressed"); + digitalWrite(remotePin, HIGH); + digitalWrite(motorPin, HIGH); + digitalWrite(BUILTIN_LED, LOW); + delay(500); + } else { + digitalWrite(remotePin, LOW); + digitalWrite(motorPin, LOW); + digitalWrite(BUILTIN_LED, HIGH); + } + delay(10); +} \ No newline at end of file