apuntes_Arduino/leds/rgb3/rgb3.ino

55 lines
1019 B
Arduino
Raw Normal View History

2021-01-05 00:15:16 -03:00
byte green = 4;
byte blue = 3;
byte red = 2;
int wait = 4000;
void setup() {
2022-04-04 17:41:38 -04:00
pinMode(green,OUTPUT);
pinMode(blue,OUTPUT);
pinMode(red,OUTPUT);
2021-01-05 00:15:16 -03:00
}
void secu1(int r) {
2022-04-04 17:41:38 -04:00
while (r>0) {
digitalWrite(green,1);
delay(wait);
digitalWrite(green,0);
digitalWrite(red,1);
delay(wait);
digitalWrite(red,0);
digitalWrite(blue,1);
delay(wait);
digitalWrite(blue,0);
--r;
}
2021-01-05 00:15:16 -03:00
}
void secu2(int r) {
2022-04-04 17:41:38 -04:00
while (r>0){
digitalWrite(blue,0);
digitalWrite(red,1);
delay(wait);
digitalWrite(green,0);
digitalWrite(blue,1);
delay(wait);
digitalWrite(red,0);
digitalWrite(green,1);
delay(wait);
--r;
}
2021-01-05 00:15:16 -03:00
}
void loop() {
2022-04-04 17:41:38 -04:00
//secu1(4);
//secu2(4);
2021-01-05 00:15:16 -03:00
digitalWrite(green,0);
digitalWrite(red,1);
delay(wait);
digitalWrite(blue,1);
digitalWrite(red,0);
delay(wait);
digitalWrite(green,1);
digitalWrite(blue,0);
delay(wait);
}