Created
January 26, 2017 09:10
-
-
Save ljahier/1a70f136a9f004e67908245920b2a85c to your computer and use it in GitHub Desktop.
capteur d'humidité 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
/* | |
* Script de detection et d'affichage de l'humidité, | |
* le taux d'humidité se doit d'être entre 50% et 70% | |
**/ | |
// Test code for Grove - Moisture Sensor | |
int sensorPin = A0; // select the input pin for the potentiometer | |
int sensorValue = 0; // variable to store the value coming from the sensor7 | |
int minHumidity = 50; | |
int maxHumidity = 70; | |
void setup() { | |
// declare the ledPin as an OUTPUT: | |
Serial.begin(9600); | |
} | |
void loop() { | |
// read the value from the sensor: | |
sensorValue = analogRead(sensorPin); | |
if (sensorValue < 0) { | |
Serial.println("Problème capteur"); | |
delay(1000); | |
} | |
if (sensorValue > maxHumidity) { | |
Serial.print("Trop humide, capteur: " ); | |
Serial.println(sensorValue); | |
delay(1000); | |
} | |
if (sensorValue < minHumidity) { | |
Serial.print("Pas assez humide: "); | |
Serial.println(sensorValue); | |
delay(1000); | |
} | |
if (sensorValue <= maxHumidity && sensorValue >= minHumidity) { | |
Serial.print("Humidite parfaite: "); | |
Serial.println(sensorValue); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment