/* Adafruit Arduino - Lesson 3. RGB LED code has been sourced from following website https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds/arduino-sketch ----------------- Modified by Darshan Shah, for Fab Academy 2018. Modifications :- - The LED pins connected to the ATtiny44 were modified, - Uncommented the " #define COMMON_ANODE " in my case (as my RGB LED has a common anode) - adding various different colors through their codes. */ /* define integer for the respective pins connected to Red, Green and Blue LED on the microcontroller*/ int redPin = 9; int greenPin = 7; int bluePin = 10; // I uncomment this line below for using a Common Anode LED //#define COMMON_ANODE // defining the type of RGB LED, in my case it has common anode void setup() { // sets the respective digital LED pins as output pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { setColor(255, 0, 0); // defining the respective color codes for loop routine delay(1500); // delay for 1 second setColor(0, 255, 100); // green delay(1000); setColor(100, 255, 0); // blue delay(5000); setColor(100, 255, 0); // I jave no idea what coolor that is delay(2000); setColor(0, 255, 100); // I jave no idea what coolor that is delay(2000); } void setColor(int red, int green, int blue) // defining function setColor, taking argument for each color { #ifdef COMMON_ANODE // checking if this is defined, which is YES // then define RGB color values red = 255 - red; // redValue green = 255 - green; // greenValue blue = 255 - blue; // blueValue #endif // end checking analogWrite(redPin, red); // setting value for red analogWrite(greenPin, green); // setting value for green analogWrite(bluePin, blue); // setting value for blue }