#include Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position // Init the Pins used for PWM const int redPin = 9; const int greenPin = 10; const int bluePin = 11; // Init the Pins used for 10K pots const int redPotPin = 0; const int greenPotPin = 1; const int bluePotPin = 2; // Init our Vars int currentColorValueRed; int currentColorValueGreen; int currentColorValueBlue; void setup() { myservo.attach(3); // attaches the servo on pin 3 to the servo object pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { //static color event 1 currentColorValueRed = 255; currentColorValueBlue = 0; currentColorValueGreen = 0; // Write the color to each pin using PWM and the value gathered above analogWrite(redPin, currentColorValueRed); analogWrite(bluePin, currentColorValueBlue); analogWrite(greenPin, currentColorValueGreen); delay(3000); //color fade event 1 currentColorValueRed = 255; currentColorValueBlue = 0; currentColorValueGreen = 0; for( int i = 0 ; i < 255 ; i += 1 ){ currentColorValueGreen += 1; currentColorValueRed -= 1; analogWrite( greenPin, 255 - currentColorValueGreen ); analogWrite( redPin, 255 - currentColorValueRed ); delay( 30 ); } delay(3000); //servo event 1 for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } //static color event 2 currentColorValueRed = 25; currentColorValueBlue = 110; currentColorValueGreen = 40; // Write the color to each pin using PWM and the value gathered above analogWrite(redPin, currentColorValueRed); analogWrite(bluePin, currentColorValueBlue); analogWrite(greenPin, currentColorValueGreen); delay(1000); }