1 //USBtinyISP(ATTinyCore) upload using programmer
4 const int RED = 4; //LED row 1
5 const int GREEN = 3; //LED row 2
6 const int BLUE = 2; //LED row 3
8 static uint16_t hue = 0; // 0-359
9 unsigned long previousMillis = 0;
13 previousMillis = millis() + 5000;
15 pinMode(GREEN, OUTPUT);
16 pinMode(BLUE, OUTPUT);
21 randomSeed(analogRead(0));
23 for (int hue=0; hue<360; hue++) {
24 setLedColorHSV(hue,random(1, 5),random(1, 5));
29 for (int hue=360; hue>0; hue--) {
30 setLedColorHSV(hue,random(1, 5),random(1, 5));
34 if (((signed long)(millis() - previousMillis)) > 0) {
35 previousMillis = millis() + 3000;
36 long dice = random(1000);
41 } else if (dice<100) {
49 void RGB_color(int red_light_value, int green_light_value, int blue_light_value) {
50 analogWrite(RED, red_light_value);
51 analogWrite(GREEN, green_light_value);
52 analogWrite(BLUE, blue_light_value);
55 void setLedColorHSV(int h, double s, double v) {
56 //this is the algorithm to convert from RGB to HSV
63 int i=(int)floor(h/60.0);
64 double f = h/60.0 - i;
65 double pv = v * (1 - s);
66 double qv = v * (1 - s*f);
67 double tv = v * (1 - s * (1 - f));
71 case 0: //rojo dominante
103 //set each component to a integer value between 0 and 255
104 int red=constrain((int)255*r,0,255);
105 int green=constrain((int)255*g,0,255);
106 int blue=constrain((int)255*b,0,255);
108 RGB_color(red,green,blue);
112 for(uint16_t t=0; t<255; t++) {
114 delay(random(1, 25));
116 for(uint16_t t=255; t>0; t--) {
118 delay(random(1, 25));
123 for(uint16_t t=0; t<255; t++) {
125 delay(random(1, 25));
127 for(uint16_t t=255; t>0; t--) {
129 delay(random(1, 25));