RGBLED \ Learning \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

This example is for Wiring version 0024+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

RGB LED by BARRAGAN
Demonstrates the use of PWM pins (analog output) to change the color of an RGB LED.

    int RED = 0;    // RED pin of the LED to PWM pin 0
    int GREEN = 1;  // GREEN pin of the LED to PWM pin 1
    int BLUE = 2;   // BLUE pin of the LED to PWM pin 2

    void setup()
    {
      // nothing for setup
    }

    void loop()
    {
      for(int r = 0; r < 1024; r+=5) {
        for(int g = 0; g < 1024; g+=5) {
          for(int b = 0; b < 1024; b+=5) {
            analogWrite(RED, r);
            analogWrite(GREEN, g);
            analogWrite(BLUE, b);
            delay(30);
          }
        }
      }
    }