// Parameterizing pin numbers for better readability and maintainability
int led1 = D0;
int led2 = D6;
int led3 = D7;
int potenciometer = A2;
int brightness; // variable for brightness
void setup() {
// Set the pinMode for LEDs and potentiometer
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(potenciometer, INPUT);
}
void loop() {
// Read the analog value from the potentiometer and scale it to a range of 0-255
brightness = analogRead(potenciometer) / 4;
// By dividing this value by 4, you are scaling the range to 0-255 compatible with analogWrite()
// Set the brightness of the LEDs based on the scaled potentiometer value
analogWrite(led1, brightness);
analogWrite(led2, brightness);
analogWrite(led3, brightness);
}
}