PLS HELP!?

This is my code why is it wrong? The blue text is where it becomes wrong in arduino.

// Connect green LED to pin 10 // Connect yellow LED to pin 11 // Connect red LED to pin 12 // Connect Piezo to pin A0

void setup() { // declare pin 10,11,12 to be outputs: // declare pin A0 to be inputs: pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(A0, INPUT); }

void loop(){{ digitalWrite(12, HIGH); // Turns LED on pin 12 on delay; } // LED on pin 12 remains on for limited seconds

pinMode(A0, INPUT); // if activated rest of the code continue

digitalWrite(12, LOW); // Turns LED on pin 12 off delay(2000);} // LED on pin 12 turns off 2 seconds

digitalWrite(11, HIGH); // Turns LED on pin 11 on delay(2000); // LED on pin 11 remains on for 2 seconds digitalWrite(11, LOW); // Turns LED on pin 11 off delay(0);

digitalWrite(10, HIGH); // Turns LED on pin 10 on delay(5000); // LED on pin 10 remains on for 5 seconds digitalWrite(10, LOW); // Turns LED on pin 10 off delay(0); }

The yellow text is where it becomes wrong in arduino.

The yellow text is a real bitch to read. Color doesn't help at all. So don't. Ever again.

You have useless curly braces. You have two open curly braces before that statement, and two after it, meaning that the end of the loop function was reached. That line, and the rest of the code, is not in a function.

Learn to code properly. Each { goes on a new line, and code between the { and the } gets indented. Then, you won't make these stupid mistakes.

PaulS:

The yellow text is where it becomes wrong in arduino.

The yellow text is a real bitch to read. Color doesn't help at all. So don't. Ever again.

I have changed the color. Btw if you have time how would you fix this problem (write the code)?

Your loop ends on this line: "delay(2000);} // LED on pin 12 turns off 2 seconds" because of "}"

I think that you don't need to use braces in the code, I think that you need only one at begining of loop and on the end of loop.

Paul said you have wonky braces… count them, as below:

// Connect green LED to pin 10
// Connect yellow LED to pin 11
// Connect red LED to pin 12
// Connect Piezo to pin A0

void setup()  { 
  // declare pin 10,11,12 to be outputs:
  // declare pin A0 to be inputs:
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(A0, INPUT);
} 

void loop(){{    //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< yoou have open open
   digitalWrite(12, HIGH); // Turns LED on pin 12 on
 delay; } // LED on pin 12 remains on for limited seconds  //<<<<<<<<<<<<<<<<<here's a close, so one open left to close
  
  pinMode(A0, INPUT); // if activated rest of the code continue
   
   digitalWrite(12, LOW); //  Turns LED on pin 12 off
 delay(2000);} // LED on pin 12 turns off 2 seconds    //<<<<<<<<<<<< here's a close, so the opens are matched
   
   digitalWrite(11, HIGH); // Turns LED on pin 11 on //<<<<<<<<<< so from here on, it's outside the loop() function
 delay(2000); // LED on pin 11 remains on for 2 seconds
   digitalWrite(11, LOW); //  Turns LED on pin 11 off

So have a think about that… clue: the closing } of loop() goes right at the end of whatever should be in the loop. And you have an unnecessary {} as Paul pointed out…

Thank you guys so much!! :)

Put each { and } on separate lines with matching pairs indented by the same amount and lines between them indented one extra level. It will make it much easier for you to recognise problems like this in future. Once you have the { and } in the right place, you can use Tools / Autoformat to correct the indentation.