Last active
August 29, 2015 14:09
-
-
Save kyab/d404843cc3691b823c32 to your computer and use it in GitHub Desktop.
fanheater_runner.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Servo.h> | |
| Servo servo; | |
| unsigned long start_ms; | |
| void moveServo(){ | |
| //attach/detach each time to avoid servo noise. | |
| servo.attach(10); | |
| servo.write(10); | |
| delay(1000); | |
| servo.write(130); | |
| delay(1000); | |
| servo.detach(); | |
| } | |
| void setup(){ | |
| Serial.begin(9600); | |
| pinMode(7, INPUT); | |
| delay(500); | |
| moveServo(); | |
| start_ms = millis(); | |
| } | |
| void loop(){ | |
| if ((millis() - start_ms) > (unsigned long)1000L * (unsigned long)60L * 100L){ //110 min was too short. | |
| moveServo(); | |
| start_ms = millis(); | |
| return; | |
| } | |
| //check switch on | |
| if (LOW == digitalRead(7)){ | |
| Serial.println("switch pressed"); | |
| moveServo(); | |
| } | |
| delay(500); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment