This code is from build.particle.com and I wrote the code in the website, when I try to verify it, it displays and error that says. I don't know how to fix it. Help would be very much appreciated. Thanks!
test.cpp: In function 'void loop()':
test.cpp:35:28: error: 'x' was not declared in this scope
delay(100);
^
make[1]: *** [../build/target/user/platform-8test.o] Error 1
make: *** [user] Error 2
Code (Original) :
int LEDGroup1 [] = {A0, A1, A2, A3};
int LEDGroup2 [] = {D4, D5, D6, D7};
int Count = 4;
int pirPin = D0; // PIR is connected to D3
void setup() {
for (int x = 0; x < Count; x++) {
pinMode(LEDGroup1[x], OUTPUT);
pinMode(LEDGroup2[x], OUTPUT);
}
}
void loop() {
// loop from the first pin to the last
int pirValState;
pirValState = digitalRead(pirPin);
if(pirValState == LOW){ // Was motion detected
for (int x = 0; x < Count; x++) {
// turn the LEDs on
digitalWrite(LEDGroup1[x], HIGH);
digitalWrite(LEDGroup2[x], HIGH);
delay(100);
// turn the LEDs off
digitalWrite(LEDGroup1[x], LOW);
digitalWrite(LEDGroup2[x], LOW);
delay(100);
}
}else{
digitalWrite(LEDGroup1[x], LOW);
digitalWrite(LEDGroup2[x], LOW);
}
}