Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int RED = 0;
- int GREEN = 1;
- int BOTTOM = 3;
- int TOP = 5;
- int ON = 12;
- int PUMP = 10;
- int pump_on = 0;
- void setup() {
- pinMode(RED, OUTPUT);
- pinMode(GREEN, OUTPUT);
- pinMode(PUMP, OUTPUT);
- pinMode(BOTTOM, INPUT_PULLUP);
- pinMode(TOP, INPUT_PULLUP);
- pinMode(ON, INPUT_PULLUP);
- }
- void loop() {
- if (digitalRead(ON) == LOW) {
- pump_on = 1;
- }
- if (digitalRead(BOTTOM) == HIGH) {
- digitalWrite(RED, HIGH);
- digitalWrite(GREEN, LOW);
- pump_on = 1;
- }
- else if (digitalRead(TOP) == LOW) {
- digitalWrite(GREEN, HIGH);
- digitalWrite(RED, LOW);
- pump_on = 0;
- }
- else {
- digitalWrite(GREEN, LOW);
- digitalWrite(RED, LOW);
- }
- if (pump_on == 1)
- digitalWrite(PUMP, HIGH);
- else
- digitalWrite(PUMP, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement