-
-
Save commak/29a056c89857a81e64a8 to your computer and use it in GitHub Desktop.
BP3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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