28 lines
568 B
C++
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);
|
|
}
|
|
}
|