const int analogInPin = 15; // GPIO15
const int analogOutPin = LED_BUILTIN; // ESP32 led
int sensorValue = 0;
int outputValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(analogInPin);
outputValue = map(sensorValue, 0, 4095, 0, 255); // ADC de 12 bits
analogWrite(analogOutPin, outputValue);
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
delay(2);
}