Advertisement
zoro-10

Humidity Sensor

Apr 1st, 2024 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. https://imgur.com/a/2eNBr5R
  2.  
  3.  
  4. const int analogIn = A1; // Connect the humidity sensor to this pin
  5. int humiditySensorOutput = 0;
  6. void setup()
  7. {
  8.   Serial.begin(9600);
  9. }
  10. void loop()
  11. {
  12.   humiditySensorOutput = analogRead(analogIn);
  13.   int humidityPercentage = map(humiditySensorOutput, 0, 1023, 10, 70);
  14.   Serial.print("Humidity: "); // Printing out Humidity Percentage
  15.   Serial.print(humidityPercentage);
  16.   Serial.println("%");
  17.   delay(5000); // Iterate every 5 seconds
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement