私は宣言した配列のリストをトリガーするループを作ろうとしています。しかし、これまでのところ何も動作していないようです。Arduinoで変数名をループする方法は?
目的は、ループにネオピクセルでアニメーションを作成させることです。配列はそのアニメーションのキーフレームですが、おそらくこれを行うためのより効率的な方法があります。しかし、これはおそらく私の要件を満たすでしょう。
は、だから私はすでにこのようにそれを試してみた:
const int startSwipe0[][4] = {whole list of numbers};
const int startSwipe1[][4] = {whole list of numbers};
const int startSwipe2[][4] = {whole list of numbers};
const int startSwipe3[][4] = {whole list of numbers};
const int startSwipe4[][4] = {whole list of numbers};
const int startSwipe5[][4] = {whole list of numbers};
void setup() {
strip.begin();
strip.setBrightness(100); // 0-255 brightness
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
currentTime = millis();
animation_a();
strip.show();
}
void animation_a() {
for (int j=0; j<6; j++) {
for (int i=0; i<NUM_LEDS; i++) {
String swipeInt = String(j);
String swipeName = "startSwipe"+swipeInt;
Serial.println(swipeName);
strip.setPixelColor(i, swipeName[i][1], swipeName[i][2], swipeName[i][3]);
}
}
}
をしかし、これは「配列の添字には無効なタイプ 『のchar [INT]』」このエラーが発生しますが、それは私の配列名と同じ名前を印刷しません。
助けてください!ありがとう!
このアプローチは、いくつかのスクリプト言語のために右のようなものですが、Arduinoのは、* *コンパイルされます。プログラムが実行されると、変数名のようなものは意味を持ちません。そのような名前はあなたとコンパイラの間にあります。 – unwind