void setup() { // initialize digital pin 5,6,7 & 8 as an output. pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); } // the loop function runs over and over again forever // Here the as pin 8 is common anode // As pins 5 and 6 are set to HIGH,the diodes connected to //blue and green LED are in reverse biased condition //therefore only the Red colour will be seen on the RGB LED void loop() { digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, LOW); digitalWrite(8, HIGH); delay(500); // Here the as pin 8 is common anode // As pins 6 and 7 are set to HIGH,the diodes connected to //blue and red LED are in reverse biased condition therefore //only the Green colour will be seen on the RGB LED digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); delay(500); // Here the as pin 8 is common anode // As pins 5 and 7 are set to HIGH,the diodes connected to //red and green LED are in reverse biased condition //therefore only the Blue colour will be seen on the RGB LED digitalWrite(5, HIGH); digitalWrite(6, LOW); digitalWrite(7, HIGH); digitalWrite(8, HIGH); delay(500); //Further mixture of colours can be produced by switching on any 2 colours at the same time }