Last active
July 7, 2018 16:32
-
-
Save i5ar/fa95e5be75e852f9a736a0f815b04223 to your computer and use it in GitHub Desktop.
Pro Micro RGB led loop
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
/* Pro Micro loop RGB led common cathode */ | |
//int yellowPin = 10; | |
//int brightness = 8; | |
//int fadeAmount = 8; | |
int redPin = 3; | |
int greenPin = 5; | |
int bluePin = 6; | |
int redAmount = 8; | |
int greenAmount = 8; | |
int blueAmount = 8; | |
int redVal = 224; | |
int greenVal = 128; | |
int blueVal = 8; | |
void setup() { | |
// pinMode(yellowPin, OUTPUT); | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
} | |
void loop() { | |
// analogWrite(yellowPin, brightness); | |
// brightness = brightness + fadeAmount; | |
analogWrite(redPin, redVal); | |
analogWrite(greenPin, greenVal); | |
analogWrite(bluePin, blueVal); | |
redVal = redVal + redAmount; | |
greenVal = greenVal + greenAmount; | |
blueVal = blueVal + blueAmount; | |
// if (brightness <= 8 || brightness >= 224) { | |
// fadeAmount = -fadeAmount; | |
// } | |
if (redVal <= 8 || redVal >= 224) { | |
redAmount = -redAmount; | |
} | |
if (greenVal <= 8 || greenVal >= 224) { | |
greenAmount = -greenAmount; | |
} | |
if (blueVal <= 8 || blueVal >= 224) { | |
blueAmount = -blueAmount; | |
} | |
delay(64); // milliseconds | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment