Instantly share code, notes, and snippets.

Embed
What would you like to do?
The Window Opener 2000
#include <Servo.h> // servo library
Servo servo1;// servo control object
const int buttonPin = 2;
int blinds = 0; // 0 is closed, 1 is open
int buttonState = 0;
void setup()
{
servo1.attach(12);
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// if button pressed and blinds are open, close the blinds
if (buttonState == LOW && blinds == 0) {
servo1.write(180);
delay(7000);
servo1.write(90);
blinds = 1;
}
// if button pressed and blinds are closed, open the blinds
else if(buttonState == LOW && blinds == 1){
servo1.write(0);
delay(7000);
servo1.write(90);
blinds = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment