#define POTENTIOMETER_PIN A0
#define LED_PIN 5
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Get the voltage reading from the Potentiometer
int potentiometerReading = analogRead(POTENTIOMETER_PIN);
//convert ADC value to the sensor’s output voltage(0-5V)
float output_voltage = (potentiometerReading*5.0)/1023.0;
// Convert the voltage into the temperature in Celsius
float temp_value = (output_voltage*10.0);
float brightness = (potentiometerReading*255.0)/1023.0;
//print ADC value (0-1023)
Serial.print("Reg: ");
Serial.print(potentiometerReading);
Serial.print(" ");
//print voltage (0-5v)
Serial.print("Output Voltage: ");
Serial.print(output_voltage,1);
Serial.print("V");
//print temperature in Celsius
Serial.print(" ");
Serial.print("temp: ");
Serial.print(temp_value,1);
Serial.print("°C");
Serial.println();
analogWrite(LED_PIN,brightness);
delay(1000);
}