/* Adafruit Arduino - Lesson 3. RGB LED Modified by Salama for Fab Academy 2018, Output Devices week. Changed pins and color code Modified by Zahrah for Fab Academy 2018, Output Devices week. Changed pins and color code */ int redPin = 1; int greenPin = 0; int bluePin = 2; //uncomment this line if using a Common Anode LED #define COMMON_ANODE void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); Serial.begin(9600); } void loop() { setColor(255, 0, 0); // red delay(500); setColor(0, 255, 0 ); //green delay(500); setColor(0, 0, 255); // blue delay(500); } void setColor(int red, int green, int blue) { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }