Skip to content

Instantly share code, notes, and snippets.

@commak
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commak/29a056c89857a81e64a8 to your computer and use it in GitHub Desktop.
Save commak/29a056c89857a81e64a8 to your computer and use it in GitHub Desktop.
BP3
//Kama Kaczmarczyk
//2483626
//prof Kate Hartman
int red = 9;
int green = 10;
int blue = 11;
int buttonPin = 5;
int buttonVal = 0;
int ledPin = 6;
void setup(){
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop(){
fader(red,green);
fader(green,blue);
fader(blue, red);
buttonVal=digitalRead(buttonPin);
if(buttonVal==HIGH){
for(int i=0; i<501;i+=100){
blinkLED(3,i);
}
}
}
void fader(int color1, int color2){
for (int brightness=0;brightness<256;brightness++){
analogWrite(color1, 255-brightness);
analogWrite(color2, brightness);
delay(10);
}
}
void blinkLED(int numBlinks, int del){
for(int i=0; i<numBlinks; i++){
digitalWrite(ledPin, HIGH);
delay(del);
digitalWrite(ledPin, LOW);
delay(del);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment