//Reto 2: Control de brillo LED con PWM
//Conectando mundos Físico - Digitales
const int ledPin = 2; // Pin para el LED
const int potentiometerPin = 4; // Pin para el potenciómetro
int potValue = 0;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
potValue = analogRead(potentiometerPin); // Lee el valor del potenciómetro
int pwmValue = map(potValue, 0, 4095, 0, 255); // Mapea el valor del potenciómetro al rango PWM (0-255)
analogWrite(ledPin, pwmValue); // Establece el brillo del LED
Serial.println(potValue);
}