Shadowcat

YL-69 Moisture sensor (Analog)

Mar 7th, 2020
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // YL-69 Moisture sensor (Analog)
  2. #define SensorPin A0
  3. float sensorValue = 0;
  4. void setup() {
  5.   Serial.begin(9600);
  6. }
  7. void loop() {
  8.   for (int i = 0; i <= 100; i++)
  9.   {
  10.     sensorValue = sensorValue + analogRead(SensorPin);
  11.     delay(1);
  12.   }
  13.   sensorValue = sensorValue / 100.0;
  14.   Serial.println(sensorValue);
  15.   delay(30);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment