dfg
sdfunknown
abap
3 years ago
1.3 kB
1
Indexable
Never
byte red_light_pin= 9; byte green_light_pin = 10; byte blue_light_pin = 11; int delay_time = 50; void setup() { //Serial.begin(9600); for(byte pin = 2; pin <= 8; pin++){ pinMode(pin, OUTPUT); } pinMode(A7, OUTPUT); randomSeed(analogRead(0)); for(int i = 2; i <= 8; i++){ digitalWrite(i, HIGH); } } void loop() { static byte counter = 0; /*if(counter == 0) RGB_color(0, 255, 255); if(counter == 1) RGB_randomColor();*/ for(byte i = 2; i <= 8; i++){ RGB_randomColor(); digitalWrite(i, LOW); delay(delay_time); digitalWrite(i, HIGH); } for(int i = 8; i >= 2; i--){ RGB_randomColor(); digitalWrite(i, LOW); delay(delay_time); digitalWrite(i, HIGH); } /*Serial.print(counter); counter++; if(counter == 2) counter = 0;*/ } void RGB_color(int red_light_value, int green_light_value, int blue_light_value){ analogWrite(red_light_pin, red_light_value); analogWrite(green_light_pin, green_light_value); analogWrite(blue_light_pin, blue_light_value); } void RGB_randomColor() { analogWrite(red_light_pin, random(0, 255)); analogWrite(green_light_pin, random(0, 255)); analogWrite(blue_light_pin, random(0, 255)); }