RGB (Red, Green, Blue) LED

This invention demonstrates how to connect a RGB (Red, Green, Blue) LED to your ThinkerShield. It is a little more complicated then a normal LED as it has additional legs, one each for red, green and blue. You can also mix and match colours by turning different colours on at different times. Please note: Your RGB LED may have the colours in a different order. It is always a good idea to experiment to make sure you know which leg is which colour.

Step 1

Gather your ThinkerShield; RGB LED; and 4 x alligator clips.

Step 2

Step 2

Connect first alligator clip to GND (ground) on your ThinkerShield and to the negative (longest, this is different to a normal LED) leg of your LED.

Step 3

Step 3

Connect second alligator clip to external pin A2 on your ThinkerShield and to the RED positive (leg to the left of ground) leg of your LED.

Step 4

Step 4

Connect third alligator clip to external pin A3 on your ThinkerShield and to the GREEN positive (leg to the right of ground) leg of your LED.

Step 5

Step 5

Connect fourth alligator clip to external pin A1 on your ThinkerShield and to the BLUE positive (leg two places to the right of ground) leg of your LED.

Step 6

// declare the pins

int red = A2;

int green = A3;

int blue = A1;


void setup() {

 // set each of the pins as outputs

 pinMode (red, HIGH);

 pinMode (green, HIGH);

 pinMode (blue, HIGH);

}


void loop() {

 // set the 

colour

 of the LED by making

 // combinations of the primary 

colours



 //purple

 digitalWrite(red, HIGH);

 digitalWrite(green, LOW);

 digitalWrite(blue, HIGH);


 delay (1000);

  
 digitalWrite(red, LOW);

 digitalWrite(green, LOW);

 digitalWrite(blue, LOW);


 delay (1000);

}

Add a comment