// the number of the LED pin
const int ledR = 4; // 16 corresponds to GPIO16
const int ledG = 16;
const int ledB = 17;
void setup() {
// set the LED as an output
pinMode(ledR, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledB, OUTPUT);
}
void loop(){
// increase the LED brightness
for(int dutyR = 0; dutyR <= 255; dutyR++){
// changing the LED brightness with PWM
analogWrite(ledR, dutyR);
delay(15);
}
// increase the LED brightness
for(int dutyG = 0; dutyG <= 255; dutyG++){
// changing the LED brightness with PWM
analogWrite(ledG, dutyG);
delay(15);
}
// increase the LED brightness
for(int dutyB = 0; dutyB <= 255; dutyB++){
// changing the LED brightness with PWM
analogWrite(ledB, dutyB);
delay(15);
}
// decrease the LED brightness
for(int dutyB = 255; dutyB >= 0; dutyB--){
// changing the LED brightness with PWM
analogWrite(ledB, dutyB);
delay(15);
}
// decrease the LED brightness
for(int dutyG = 255; dutyG >= 0; dutyG--){
// changing the LED brightness with PWM
analogWrite(ledG, dutyG);
delay(15);
}
// decrease the LED brightness
for(int dutyR = 255; dutyR >= 0; dutyR--){
// changing the LED brightness with PWM
analogWrite(ledR, dutyR);
delay(15);
}
}