const int analogInPin = 2; // Analog input pin that the potentiometer is attached to
int sensorValue = 0;
void setup() {
Serial.begin(115200); // Initialize serial communication at 115200 baud rate
analogSetAttenuation(ADC_11db); // Set attenuation to 0 dB (default)
// Available attenuation options:
// ADC_0db: No attenuation, 0-1V
// ADC_2_5db: Attenuation 2.5dB, 0-1.34V
// ADC_6db: Attenuation 6dB, 0-2V
// ADC_11db: Attenuation 11dB, 0-3.6V (Recommended for most applications)
}
void loop() {
// Read the analog value from pin 2
sensorValue = analogRead(analogInPin);
// Print the sensor value to the Serial Monitor
Serial.print("Analog value from pin 2: ");
Serial.println(sensorValue);
delay(1000); // Delay in milliseconds (1 second)
}