Last active
April 2, 2018 14:19
-
-
Save nikibobi/92f803a1e8acc309356e to your computer and use it in GitHub Desktop.
This file contains 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
#define T 30 | |
#define PIN_START 3 | |
#define PIN_TOP 4 | |
#define PIN_BOT 5 | |
#define PIN_DOWN 7 | |
#define PIN_UP 9 | |
void setup() { | |
pinMode(PIN_START, INPUT); | |
pinMode(PIN_TOP, INPUT); | |
pinMode(PIN_BOT, INPUT); | |
pinMode(PIN_DOWN, OUTPUT); | |
pinMode(PIN_UP, OUTPUT); | |
goNo(); | |
} | |
void loop() { | |
if(digitalRead(PIN_START) == LOW) | |
return; | |
goDown();//start going down | |
while(digitalRead(PIN_BOT) == LOW);//untill we hit rock bottom | |
goNo();//then stop | |
delay(T * 1000);//then wait T seconds | |
goUp();//start going up | |
while(digitalRead(PIN_TOP) == LOW);//untill we hit sky top | |
goNo();//and stop | |
} | |
void goDown() { | |
digitalWrite(PIN_UP, LOW); | |
digitalWrite(PIN_DOWN, HIGH); | |
} | |
void goUp() { | |
digitalWrite(PIN_DOWN, LOW); | |
digitalWrite(PIN_UP, HIGH); | |
} | |
void goNo() { | |
digitalWrite(PIN_DOWN, LOW); | |
digitalWrite(PIN_UP, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment