Code Shield RGB Tests and Demos

This page contains several sketches that test or demonstrate the operation of the RGB LED.

/* Diyode CodeShield Base Script

this test cycles the RGB LED through all 16 000 000 colours this

this test takes approximately 4 hours to run.

*/

#define ENCODER_A 14

#define ENCODER_B 15

#define ENCODER_PORT PINC

#define SWITCH 13

#define BUTTON 12

#define RGB_RED 11

#define RGB_GREEN 10

#define RGB_BLUE 9

#define LED 6

#define SERVO 5

#define PIEZO 3

#define RELAY 2

#define POT 2

#define HALL 3

#define THERMISTOR 4

#define PHOTOCELL 5

void setup() {

pinMode(RGB_RED, OUTPUT);

pinMode(RGB_GREEN, OUTPUT);

pinMode(RGB_BLUE, OUTPUT);

Serial.begin(9600);

}

void loop() {

for(int red =0; red< 255; red++){

for(int green =0; green< 255; green++){

for(int blue =0; blue< 255; blue++){

analogWrite(RGB_RED, red);

analogWrite(RGB_GREEN, green);

analogWrite(RGB_BLUE, blue);

Serial.print("Red ");

Serial.println(red );

Serial.print("Green ");

Serial.println(green );

Serial.print("Blue ");

Serial.println(blue );

Serial.println(" ");`

}

}

}

}

This sketch tests the operation of the RGB LED Blue phase controlled by the switch. the Sketch is easily modified to test the Red and Green phases by replacing the uppercase work BLUE in the setup and loop functions with the word RED or GREEN

/* Diyode CodeShield Base Script */

#define ENCODER_A 14

#define ENCODER_B 15

#define ENCODER_PORT PINC

#define SWITCH 13

#define BUTTON 12

#define RGB_RED 11

#define RGB_GREEN 10

#define RGB_BLUE 9

#define LED 6

#define SERVO 5

#define PIEZO 3

#define RELAY 2

#define POT 2

#define HALL 3

#define THERMISTOR 4

#define PHOTOCELL 5

void setup() {

pinMode(SWITCH, INPUT);

pinMode(RGB_BLUE, OUTPUT);

}

void loop() {

digitalWrite(RGB_BLUE, digitalRead(SWITCH));

}