Arduino soil moisture

De The Linux Craftsman
Aller à la navigation Aller à la recherche
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
// PIN en entrée pour la photorésistance
int sensorPin = A0;
float sensorValue = 0;
float percent = 0;
void setup() {
   Serial.begin(9600);
}
void loop() {
   // Lit la valeur du capteur
   sensorValue = analogRead(sensorPin);
   percent = ((sensorValue/789)*100);
   
   Serial.print(F("Humidity: "));
   Serial.println(percent, 6);
   delay(500);
}