Created
November 3, 2015 01:12
-
-
Save Palakis/587c2585dcc244431fcc to your computer and use it in GitHub Desktop.
Arduino LED fun
This file contains 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
#define ROUGE 9 | |
#define VERT 10 | |
#define BLEU 11 | |
#define ROUGE2 3 | |
#define VERT2 5 | |
#define BLEU2 6 | |
#define DELAI 50 | |
#define PAUSE 0 | |
int maxi = 255; | |
int r = 255; | |
int v = 0; | |
int b = 0; | |
int lum(int val) { | |
//bougie(); | |
return map(val, 0, 255, 0, maxi); | |
} | |
void bougie() { | |
maxi = random(50,255); | |
} | |
void setup() { | |
Serial.begin(9600); | |
analogWrite(ROUGE, 255); | |
analogWrite(ROUGE2, 255); | |
delay(PAUSE); | |
} | |
void loop() { | |
for(v = 0; v <= 255; v +=5) { | |
analogWrite(VERT, lum(v)); | |
analogWrite(VERT2, lum(v)); | |
r -= 5; | |
if(r < 0) { | |
r = 0; | |
} | |
if(v == 125) { | |
delay(PAUSE); | |
} | |
analogWrite(ROUGE, lum(r)); | |
analogWrite(ROUGE2, lum(r)); | |
Serial.print(r); | |
Serial.print(","); | |
Serial.print(v); | |
Serial.print(","); | |
Serial.println(b); | |
delay(DELAI); | |
} | |
delay(PAUSE); | |
for(b = 0; b <= 255; b +=5) { | |
analogWrite(BLEU, lum(b)); | |
analogWrite(BLEU2, lum(b)); | |
v -= 5; | |
if(v < 0) { | |
v = 0; | |
} | |
if(b == 125) { | |
delay(PAUSE); | |
} | |
analogWrite(VERT, lum(v)); | |
analogWrite(VERT2, lum(v)); | |
Serial.print(r); | |
Serial.print(","); | |
Serial.print(v); | |
Serial.print(","); | |
Serial.println(b); | |
delay(DELAI); | |
} | |
delay(PAUSE); | |
for(r = 0; r <= 255; r +=5) { | |
analogWrite(ROUGE, lum(r)); | |
analogWrite(ROUGE2, lum(r)); | |
b -= 5; | |
if(b < 0) { | |
b = 0; | |
} | |
if(r == 125) { | |
delay(PAUSE); | |
} | |
analogWrite(BLEU, lum(b)); | |
analogWrite(BLEU2, lum(b)); | |
Serial.print(r); | |
Serial.print(","); | |
Serial.print(v); | |
Serial.print(","); | |
Serial.println(b); | |
delay(DELAI); | |
} | |
delay(PAUSE); | |
} |
This file contains 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
#define ROUGE 3 | |
#define VERT 5 | |
#define BLEU 6 | |
#define ROUGE2 9 | |
#define VERT2 10 | |
#define BLEU2 11 | |
#define PAUSE 100 | |
#define TEMPS 50 | |
void setup() { | |
} | |
void loop() { | |
analogWrite(ROUGE, random(0, 255)); | |
analogWrite(ROUGE2, random(0, 255)); | |
analogWrite(VERT, random(0, 255)); | |
analogWrite(VERT2, random(0, 255)); | |
analogWrite(BLEU, random(0, 255)); | |
analogWrite(BLEU2, random(0, 255)); | |
delay(TEMPS); | |
analogWrite(ROUGE, 0); | |
analogWrite(ROUGE2, 0); | |
analogWrite(VERT, 0); | |
analogWrite(VERT2, 0); | |
analogWrite(BLEU, 0); | |
analogWrite(BLEU2, 0); | |
delay(PAUSE); | |
} |
This file contains 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
#define ROUGE 3 | |
#define VERT 5 | |
#define BLEU 6 | |
#define ROUGE2 9 | |
#define VERT2 10 | |
#define BLEU2 11 | |
#define PAUSE 70 | |
#define TEMPS 50 | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
int index1 = round(random(5, 8)); | |
switch(index1) { | |
case 5: | |
analogWrite(ROUGE, 255); | |
break; | |
case 6: | |
analogWrite(VERT, 255); | |
break; | |
case 7: | |
analogWrite(BLEU, 255); | |
break; | |
} | |
int index2 = round(random(5, 8)); | |
switch(index2) { | |
case 5: | |
analogWrite(ROUGE2, 255); | |
break; | |
case 6: | |
analogWrite(VERT2, 255); | |
break; | |
case 7: | |
analogWrite(BLEU2, 255); | |
break; | |
} | |
Serial.print(index1); | |
Serial.print(";"); | |
Serial.println(index2); | |
delay(TEMPS); | |
analogWrite(ROUGE, 0); | |
analogWrite(ROUGE2, 0); | |
analogWrite(VERT, 0); | |
analogWrite(VERT2, 0); | |
analogWrite(BLEU, 0); | |
analogWrite(BLEU2, 0); | |
delay(PAUSE); | |
} |
This file contains 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
#define ROUGE 3 | |
#define VERT 5 | |
#define BLEU 6 | |
#define ROUGE2 9 | |
#define VERT2 10 | |
#define BLEU2 11 | |
#define PAUSE 100 | |
#define TEMPS 50 | |
void setup() { | |
} | |
void loop() { | |
analogWrite(ROUGE, random(0, 255)); | |
analogWrite(ROUGE2, random(0, 255)); | |
analogWrite(VERT, random(0, 255)); | |
analogWrite(VERT2, random(0, 255)); | |
analogWrite(BLEU, random(0, 255)); | |
analogWrite(BLEU2, random(0, 255)); | |
delay(TEMPS); | |
analogWrite(ROUGE, 0); | |
analogWrite(ROUGE2, 0); | |
analogWrite(VERT, 0); | |
analogWrite(VERT2, 0); | |
analogWrite(BLEU, 0); | |
analogWrite(BLEU2, 0); | |
delay(PAUSE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment