I am relatively new to Arduino and C++ and I am stuck on this error. I am trying to have LEDs streak across a matrix at the same time.
The error message I receive is
"exit status 1. expected ')' before ';' token"
Any help would be great.
#define NUM_LEDS 64
#define DATA_PIN 3
CRGB leds[NUM_LEDS];
int count1 = 0;
int count2 = 0;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
for ((count1 = 0; count1 <= 15; count1++) and (count2 = 31; count2 >= 16; count2--)) {
leds[count1] = CRGB::Blue;
leds[count2] = CRGB::Blue;
FastLED.show();
delay(100);
leds[count1] = CRGB::Black;
leds[count2] = CRGB::Black;
}
}
Your for
loop doesn't work.
A for
loop is: for
( initial
; test
; update
)
You have all of those three parts twice with an "and" between them, that is invalid syntax.
for ((count1 = 0; count1 <= 15; count1++) and (count2 = 31; count2 >= 16; count2--)) {
<- Invalid!
What you can do is this:
for (count1 = 0, count2 = 31; count1 <= 15 && count2 >= 16; count1++, count2--)