Last active
August 21, 2017 07:50
-
-
Save HorlogeSkynet/86dc215ccf0a0a4b55ddad460a5fd49c to your computer and use it in GitHub Desktop.
Simple code which modelises a self reliant parasol 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 relais = 4; | |
const int switch_haut = 3; | |
const int switch_bas = 2; | |
const int photoresistance = A0; | |
const int anemometre = A1; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(relais, OUTPUT); | |
pinMode(switch_haut, INPUT); | |
pinMode(switch_bas, INPUT); | |
} | |
void loop() | |
{ | |
float luminosite = 0; | |
luminosite = analogRead(photoresistance); | |
Serial.print("Luminosite: "); | |
Serial.print(luminosite); | |
Serial.println("."); | |
float vent = 0; | |
vent = analogRead(anemometre); | |
Serial.print("Vent: "); | |
Serial.print(vent); | |
Serial.println(" km/h."); | |
if(vent <= 15) | |
{ | |
if(luminosite >= 830) | |
{ | |
while(digitalRead(switch_haut) == LOW) | |
{ | |
digitalWrite(relais, HIGH); | |
} | |
digitalWrite(relais, LOW); | |
} | |
} | |
else | |
{ | |
while(digitalRead(switch_bas) == LOW) | |
{ | |
digitalWrite(relais, LOW); | |
} | |
digitalWrite(relais, HIGH); | |
} | |
delay(300000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment