// Define the analog pin where the humidity sensor is connected const int humiditySensorPin = A2; // Variable to store the sensor value int sensorValue = 0; void setup() { // Initialize the serial communication Serial.begin(9600); } void loop() { // Read the analog value from the sensor sensorValue = analogRead(humiditySensorPin); // Convert the analog value to a voltage (assuming a 3.3V reference) float voltage = sensorValue * (3.3 / 1023.0); // Convert the voltage to a humidity percentage // (Assuming the sensor output is linearly related to humidity and scaled appropriately) float humidity = (voltage / 3.3) * 100.0; // Print the humidity value to the Serial Monitor Serial.print("Humidity: "); Serial.print(humidity); Serial.println("%"); // Wait for 1 second before taking the next reading delay(1000); }