apuntes_Arduino/leds/RGBx2/RGBx2.ino

112 lines
2.0 KiB
Arduino
Raw Normal View History

2021-01-05 00:15:16 -03:00
#define fan_1 11
#define fan_2 10
//byte pines[] = {red_1, blu_1, gre_1, red_2, blu_2, gre_2};
//byte cant_pin;
int veloc = 5;
void setup() {
Serial.begin(115200);
pinMode(fan_1,OUTPUT);
pinMode(fan_2,OUTPUT);
//pinMode(gre_1,OUTPUT);
//pinMode(red_2,OUTPUT);
//pinMode(blu_2,OUTPUT);
//pinMode(gre_2,OUTPUT);
//cant_pin = sizeof(pines);
}
void loop() {
analogWrite(fan_1, 100);
delay(2000);
analogWrite(fan_1, 100);
delay(5000);
analogWrite(fan_1, 255);
delay(10000);
/*
byte b, g, r;
for (r=0; r<86; r++) {
b = 170 - r;
g = 85 - r;
rgb(r, b, g);
delay(veloc);
}
for (g = 0; g<86; g++) {
r = g + 85;
b = 85 - g;
rgb(r, b, g);
delay(veloc);
}
for (b=0; b<86; b++) {
r = b + 170;
g = b + 85;
rgb(r, b, g);
delay(veloc);
}
g=170;
b=85;
for (r=255; r>169; r--){
g++;
b++;
rgb(r, b, g);
delay(veloc);
}
b=170;
r=170;
for (g=255; g>169; g--){
b++;
r--;
rgb(r, b, g);
delay(veloc);
}
r=85;
g=170;
for(b=255; b>169; b--){
r--;
g--;
rgb(r, b, g);
delay(veloc);
}
for(byte r=0; r<256; r++) {
byte b = r - 85;
byte g = b - 85;
analogWrite(red_1, b);
analogWrite(blu_1, g);
analogWrite(gre_1, r);
analogWrite(red_2, g);
analogWrite(blu_2, r);
analogWrite(gre_2, b);
//Serial.println("R = "+String(i)+", B = "+String(b)+", G = "+String(g));
delay(10);
}
for (byte i=0; i < cant_pin; i++) {
byte r = random(256);
analogWrite(pines[i], r);
delay(100);
}
analogWrite(blu_1, 0);
analogWrite(blu_2, 0);
analogWrite(red_1, 0);
analogWrite(red_2, 0);
analogWrite(gre_1, 0);
analogWrite(gre_2, 0);
delay(10000);
*/
}
/*
void rgb(byte rojo, byte azul, byte verde) {
analogWrite(red_1, rojo);
analogWrite(blu_1, azul);
analogWrite(gre_1, verde);
analogWrite(red_2, rojo);
analogWrite(blu_2, azul);
analogWrite(gre_2, verde);
}
*/