Need Help with Code, Don't know how to fix code error

This code is from 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

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);
// turn the LEDs off
digitalWrite(LEDGroup1[x], LOW);
digitalWrite(LEDGroup2[x], LOW);



digitalWrite(LEDGroup1[x], LOW);
digitalWrite(LEDGroup2[x], LOW);



When you copy from Website the characters will change and cause the compiler error.

Try copy the code to code tag and post it again.

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

At the moment your code has strange characters in it.


Your web address isn't right either. It causes an "unknown" error.

This is also a crosspost.

johnwasser answered your question yesterday morning in your other thread, but you never responded to any of th posters there. Yet you re-ask here.

What's up?

Thread locked