Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Extend the previously developed circuit so that all three channels of the RGB LED strip can be controlled differently.
  2. Program a color colour change which that fades between red, green and blue (logic: off>red>green>blue>off).

...

languagejava
titleLösung Aufgabe 1
collapsetrue

...


Code Block
languagejava
titleSolution Exercise 2
collapsetrue
#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);
  }
}

...