/* Arduino Starter Kit example Project 4 - Color Mixing Lamp This sketch is written to accompany Project 3 in the Arduino Starter Kit Parts required: 1 RGB LED three 10 kilohm resistors 3 220 ohm resistors 3 photoresistors red green and blue colored gels Created 13 September 2012 Modified 14 November 2012 by Scott Fitzgerald Thanks to Federico Vanzati for improvements http://www.arduino.cc/starterKit This example code is part of the public domain */ /* ATtiny Pin 2 to Arduino Pin 13 (or SCK of another programmer) ATtiny Pin 1 to Arduino Pin 12 (or MISO of another programmer) ATtiny Pin 0 to Arduino Pin 11 (or MOSI of another programmer) ATtiny Reset Pin to Arduino Pin 10 (or RESET of another programmer) */ const int greenLEDPin = 0; // LED connected to digital pin 9 const int redLEDPin = 2; // LED connected to digital pin 10 const int blueLEDPin = 1; // LED connected to digital pin 11 int redValue = 255; // value to write to the red LED int greenValue = 255; // value to write to the green LED int blueValue = 0; // value to write to the blue LED void setup() { // set the digital pins as outputs pinMode(greenLEDPin, OUTPUT); pinMode(redLEDPin, OUTPUT); pinMode(blueLEDPin, OUTPUT); } void loop() { analogWrite(redLEDPin, redValue); analogWrite(greenLEDPin, greenValue); for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) { // sets the value (range from 0 to 255): analogWrite(blueLEDPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) { // sets the value (range from 0 to 255): analogWrite(blueLEDPin, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(30); } }