我总共有一组LED 12:6个是蓝色,6个是红色。我有一些循环,有助于杂乱地以设定的间隔打开和关闭LED。但现在我想做到这一点,它有while循环控制LED的速度变化多长时间。到目前为止我已经做了两个并且它们都工作了但是第二个我把for循环放在它里面并没有做任何事情。
int redLEDPins[] = {2,3,4,5,6,7};
int blueLEDPins[] = {8,9,10,11,12,13};
int LED_Amount = 6;
int led_delay = 1000;
unsigned long time_since_last_reset = 0;
int wail = 5000;
int yelp = 3000;
int phaser = 3000;
int hilo = 3000;
void setup() {
for (int i; i < LED_Amount; i++) {
pinMode(redLEDPins[i], OUTPUT);
pinMode(blueLEDPins[i], OUTPUT);
}
Serial.begin(9600);
}
void loop() {
//wail while loop
time_since_last_reset = millis();
while((millis() - time_since_last_reset) < wail) {
led_delay = 250;
Serial.print("delay: ");
Serial.println(led_delay);
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
delay(500);
}
//yelp while loop
time_since_last_reset = millis();
while((millis() - time_since_last_reset) < wail){
led_delay = 50;
Serial.print("delay: ");
Serial.println(led_delay);
for (int i; i < LED_Amount; i++) {
digitalWrite(redLEDPins[i], HIGH);
digitalWrite(blueLEDPins[i], LOW);
Serial.println("Red on ");
Serial.println("Blue off");
}
delay(led_delay);
for (int i; i < LED_Amount; i++){
digitalWrite(redLEDPins[i], LOW);
digitalWrite(blueLEDPins[i], HIGH);
Serial.println("Red off ");
Serial.println("Blue on");
}
delay(led_delay);
}
}
答案 0 :(得分:1)
theData= [[0, 1, 1, 1],[0, 1, 3, 1],[3, 4, 1, 3],[0, 1, 2, 0],[2, 1, 0, 0]]
可能是因为你没有初始化我?