...
- Extend the previously developed circuit so that all three channels of the RGB LED strip can be controlled differently.
- Program a color colour change which that fades between red, green and blue (logic: off>red>green>blue>off).
...
| language | java |
|---|---|
| title | Lösung Aufgabe 1 |
| collapse | true |
...
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
#define RED_LED 11 // PWM Pin
#define GRN_LED 10 // PWM PIN
#define BLU_LED 9 // PWM fPIN
void setup()
{
pinMode(RED_LED, OUTPUT);
pinMode(GRN_LED, OUTPUT);
pinMode(BLU_LED, OUTPUT);
}
void loop()
{
for (int i = 0; i < 255; i++)
{
analogWrite(RED_LED, i);
delay(10);
}
for (int i = 255; i > 0; i--)
{
analogWrite(RED_LED, i); // D
analogWrite(GRN_LED, (-1) * (255 - i));
delay(10);
}
for (int i = 255; i > 0; i--)
{
analogWrite(GRN_LED, i);
analogWrite(BLU_LED, (-1) * (255 - i));
delay(10);
}
for (int i = 255; i > 0; i--)
{
analogWrite(BLU_LED, i);
delay(10);
}
} |
...