Skip to content

Instantly share code, notes, and snippets.

@odrix
Last active August 29, 2015 14:13
Show Gist options
  • Save odrix/38763aa1329537318dad to your computer and use it in GitHub Desktop.
Save odrix/38763aa1329537318dad to your computer and use it in GitHub Desktop.
Led RGB Change Color Circle gradient
#define pinRouge 9
#define pinVert 10
#define pinBleu 11
int couleur=1;
int ledrgb[] = {0,0,255};
int valNuance = 17;
int nbNuance = 15;
// valNuance * nbNuance = 255
void setup() {
pinMode(pinRouge, OUTPUT);
pinMode(pinVert, OUTPUT);
pinMode(pinBleu, OUTPUT);
}
void loop() {
for(int i=0;i<nbNuance;i++) {
ledrgb[couleur] += valNuance;
allumeLed(ledrgb[0], ledrgb[1], ledrgb[2]);
delay(50);
}
valNuance *= -1;
couleur++;
if(couleur>2)
couleur=0;
}
void allumeLed(int pwmRouge, int pwmVert, int pwmBleu) {
analogWrite(pinRouge, pwmRouge);
analogWrite(pinVert, pwmVert);
analogWrite(pinBleu, pwmBleu);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment