Last active
August 21, 2017 07:50
-
-
Save HorlogeSkynet/ca755c1e4dcc088501b73aa8a6715173 to your computer and use it in GitHub Desktop.
Simple code which modelises a water fountain on Arduino
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
const int switchG = 2; | |
const int switchA = 3; | |
const int switchB = 4; | |
const int switchC = 5; | |
const int vanne = 6; | |
int switchGstate = 0; | |
int switchAstate = 0; | |
int switchBstate = 0; | |
int switchCstate = 0; | |
unsigned long TEMPS_DEBUTA; | |
unsigned long TEMPS_A; | |
unsigned long Volume_A; | |
unsigned long TEMPS_DEBUTB; | |
unsigned long TEMPS_B; | |
unsigned long Volume_B; | |
unsigned long TEMPS_DEBUTC; | |
unsigned long TEMPS_C; | |
unsigned long Volume_C; | |
void setup() | |
{ | |
pinMode(switchG, INPUT); | |
pinMode(switchA, INPUT); | |
pinMode(switchB, INPUT); | |
pinMode(switchC, INPUT); | |
pinMode(vanne, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
switchGstate = digitalRead(switchG); | |
switchAstate = digitalRead(switchA); | |
switchBstate = digitalRead(switchB); | |
switchCstate = digitalRead(switchC); | |
if(switchGstate == HIGH) | |
{ | |
digitalWrite(vanne, HIGH); | |
} | |
else | |
{ | |
digitalWrite(vanne, LOW); | |
} | |
if(switchAstate == HIGH) | |
{ | |
if(switchGstate == LOW) | |
{ | |
TEMPS_DEBUTA = millis(); | |
} | |
else | |
{ | |
TEMPS_A = millis() - TEMPS_DEBUTA; | |
Volume_A = TEMPS_A / 333; | |
Serial.print("Volume Servi A: "); | |
Serial.println(Volume_A); | |
delay(333); | |
} | |
} | |
if(switchBstate == HIGH) | |
{ | |
if(switchGstate == LOW) | |
{ | |
TEMPS_DEBUTB = millis(); | |
} | |
else | |
{ | |
TEMPS_B = millis() - TEMPS_DEBUTB; | |
Volume_B = TEMPS_B / 333; | |
Serial.print("Volume Servi B: "); | |
Serial.println(Volume_B); | |
delay(333); | |
} | |
} | |
if(switchCstate == HIGH) | |
{ | |
if(switchGstate == LOW) | |
{ | |
TEMPS_DEBUTC = millis(); | |
} | |
else | |
{ | |
TEMPS_C = millis() - TEMPS_DEBUTC; | |
Volume_C = TEMPS_C / 333; | |
Serial.print("Volume Servi C: "); | |
Serial.println(Volume_C); | |
delay(333); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment