Files
Arduino/PWM_TEST/PWM_TEST.ino
Jérôme Delacotte 7b30d6e298 first commit
2025-03-06 11:15:32 +01:00

28 lines
568 B
C++

/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com
*********/
const int ledPin = D2;
void setup() {
pinMode(ledPin,OUTPUT);
}
void loop() {
// increase the LED brightness
for(int dutyCycle = 0; dutyCycle < 255; dutyCycle++){
// changing the LED brightness with PWM
analogWrite(ledPin, dutyCycle);
delay(10);
}
// decrease the LED brightness
for(int dutyCycle = 255; dutyCycle > 0; dutyCycle--){
// changing the LED brightness with PWM
analogWrite(ledPin, dutyCycle);
delay(10);
}
}