Skip to content

Instantly share code, notes, and snippets.

@HorlogeSkynet
Last active August 21, 2017 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HorlogeSkynet/86dc215ccf0a0a4b55ddad460a5fd49c to your computer and use it in GitHub Desktop.
Save HorlogeSkynet/86dc215ccf0a0a4b55ddad460a5fd49c to your computer and use it in GitHub Desktop.
Simple code which modelises a self reliant parasol on Arduino
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