Garage.ino
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user