Error after adding a few extra line, probably something REALLY simple

Ive added a few extra line to my sketch today (146-178) and I am left with the message below, Ive been over and over it and cant see what Ive missing. It going to be something really obvious and simple, Its baking my head

nanocode1_buzzer.ino: In function 'void loop()':
nanocode1_buzzer:151: error: 'playBuzzer' was not declared in this scope
nanocode1_buzzer:158: error: a function-definition is not allowed here before '{' token
nanocode1_buzzer:287: error: expected }' at end of input nanocode1_buzzer:287: error: expected }' at end of input

/* Written by Venderbroeck. */
/*free to use, but a reference would be nice =) */

#include <LiquidCrystal.h>

 //Setting up LCD
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD interface pins
 
  //transistor on pin 9
 int speedsignal = 9;
 
  //Piezo on pin 10
 int piezo = 10;
 
 //LED on pin 8
 int egtled = 8; 
 
 //declaring storage array
  int storage[60];  //megadataframe[60]
 
 //declaring byteIn in which to temporarely store bytes recieved by
 //the serial connection.
 int byteIn = 0;
 
 //declaring bools for header recognition script
 bool checkheader1 = false;
 bool checkheader2 = false;
 
 //declaring trigger bool, used to trigger void loop script
 bool trigger = false; //frametrigger
 
 //counter for the loop filling the storage array with data from the MEGA
 int i = 1; 
 
 //Declaring display value vars
 int IATvalue = 0;
 int EGTvalue = 0;
 int AFRvalue = 0;
 int BOOSTvalue = 0;
 int SPEEDvalue = 0;
 //BOOST/VAC
 float rawval = 0; // Setup raw sensor value
 float boost = 0; // Setup boost value
 float vac = 0; // Setup vacuum value
 //AFR
 float rawvala = 0; // Setup raw afr sensor value
 float afr = 0; // Setup value for afr value 
 //EGT
 int rawvale = 0; // Setup raw egt sensor value
 int egt = 0; // Setup value for egt value
 //SPEED
 int rawspeedval = 0; // Setup raw egt sensor value
 int speedval = 0; // Setup value for egt value

 void setup() {
   {  
  pinMode(egtled, OUTPUT); //Define EGT high LED  
  pinMode(piezo, OUTPUT); //Define EGT high piezo   
  pinMode(speedsignal, OUTPUT); //Define speed signal switch  
 } 
         // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);

  lcd.setCursor(4,0); //set cursor to top left corner
  lcd.print("Volvo V70 R"); //print the text to the lcd
  lcd.setCursor(3,2); //set cursor to top left corner
  lcd.print("Custom tune by"); //print the text to the lcd
  lcd.setCursor(5,3); //set cursor to top left corner
  lcd.print("Avinitlarge"); //print the text to the lcd
  {
    delay(2000);  //change the delay to change how fast the boot up screen changes 
  }
   
 /*configuring lcd stuff*/
 
 lcd.begin(20, 4); // set the LCD's columns and rows
 
 // Setup static characters on the lcd
  lcd.setCursor(2,0);
  lcd.print("IAT:");
  lcd.setCursor(2,1);
  lcd.print("EGT:");
  lcd.setCursor(2,2);
  lcd.print("AFR:");
  lcd.setCursor(0,3);
  lcd.print("BOOST:");

 Serial.begin(9600); 

 }
 
void loop() {
  
   if (trigger == true) { 
     IATvalue = storage[1];
     EGTvalue = storage[2];
     AFRvalue = storage[3];
     BOOSTvalue = storage[4];
     SPEEDvalue = storage[5];

    /*add code here to values to lcd*/
//IAT Gauge start
  lcd.setCursor(7,0);
  lcd.print(IATvalue,1); // Prints the IAT figure
  lcd.print((char)178);
  lcd.print("C ");
//IAT Gauge end

//Speed Gauge start
  // some base calculations to get speed
  rawspeedval = (SPEEDvalue); // Calculate speed value from raw value for debugging
  speedval = (rawspeedval*(0.621371)); // Calculate afr from raw value ***(calculations need proving)***
// lcd.setCursor(7,2);
// lcd.print(afr,1); // Prints the speed figure
//AFR Gauge end
   if (speedval < 15) // set for temp for LED to switch on  
  {  
   digitalWrite(speedsignal, HIGH);  
  }  
  else    
  {  
   digitalWrite(speedsignal, LOW);  
  }  
//Speed Gauge end
  
//EGT Gauge start
  rawvale = (EGTvalue); // Calculate afr value from raw value for debugging
  egt = (rawvale*(4)); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,1);
  lcd.print(egt,1); // Prints the EGT figure
  lcd.print((char)178);
  lcd.print("C ");
//EGT Gauge end

//EGT LED warning start
 // if (egt > 800) // set for temp for LED to switch on  
//  {  
 //  digitalWrite(egtled, HIGH);  
 // }  
 // else    
 // {  
//   digitalWrite(egtled, LOW);  
//  }  
//EGT LED warning end

//EGT piezo warning start
   
  if(egt > 800)
   {
    // sound buzzer
  playBuzzer(piezo);
   }

  delay(100);
}

void playBuzzer(int piezo)
{
  for(int i = 0; i < 3; ++i)
  {
    // alternate between two tones, one high and one low
    // at the same time alternate the blue and red LED flashing
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 400);          // play 400 Hz tone for 500 ms 
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
    
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 800);          // play 800Hz tone for 500ms
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
  }

  // Stop the buzzer
  noTone(piezo);
}

//EGT piezo warning end
  
  
//AFR Gauge start
  // some base calculations to get afr
  rawvala = (AFRvalue); // Calculate afr value from raw value for debugging
  afr = (rawvala*(0.03671875)+10); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,2);
  lcd.print(afr,1); // Prints the afr figure
//AFR Gauge end

//Boost gauge start
// some base calculations to get pressures
 rawval = (BOOSTvalue); // Read MAP sensor raw value on analog port 0
 //kpaval = (rawval*(0.004)/(0.022)+20); // Calculate kpa value from raw value for debugging
 boost = ((((rawval/255) + 0.04)/0.004)*0.145) - 14.528; // Calculate psi from raw value ***(calculations need proving)***


if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
  {
  lcd.setCursor(7,3);
  lcd.print(boost,1); // Prints the BOOST figure
  lcd.setCursor(11,3);
  lcd.print("psi "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'

  }

if (boost < 0)
  {
  lcd.setCursor(7,3);
  lcd.print(vac,1); // Prints the vacuum figure
  vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
  lcd.setCursor(11,3); 
  lcd.print("inHg"); // Changes the units to 'inHg' on the lcd
  
  }


//BOOST Gauge end
  
    /**/
     
    trigger = false; 
   }
 }

 void serialEvent() {
  //Run the while loop for as long as serial data is available.
  //Keep in mind the whole loop will iterate once for each incoming byte.
   while (Serial.available() ) {
    //reset byteIn variable. Might be redundant.
    byteIn = 0;
    //take byte out of the serial 3 buffer and store it.
    byteIn = Serial.read();

    /*the next if statements need to be ran in this specific order.
    They look for the header and store the MEGA dataframe in 'storage' for 
    later use by the nano.
    MEGA header = 5F AF
    MEGA footer = B4 64 */


    //If both the headerbytes have been recieved and i == 5,
    //the loop storing the body has allready been completed, so 
    //both checkheader triggers reset to false and i resets to 1
    //Also it will set the void loop trigger to true to run the script it contains.
      if (checkheader1 == true && checkheader2 == true && i == 5) {
       checkheader1 = false;
       checkheader2 = false;
       trigger = true;
       i = 1; 

     }

    //ERRORCHECK
    //If first headerbyte was recieved, and the second was not, 
    //and the byte stored isn't AF, something went 
    //wrong and checkheader1, and i both reset.
      if (checkheader1 == true && checkheader2 == false && byteIn != 0xAF) {
       checkheader1 = false;
       i = 1;
      }

    /*The actual part filling the array. Everytime the while(serial available())
    loop iterates, and the headertriggers are set true, and nothing was changed 
    above this will write the byte stored in byteIn to the proper place in storage. 
    Note that i is incremented here each iteration. When it reaches 5 (all bytes recieved)
    all triggers, including i are reset above in the next loop iteration. */
     if(checkheader1 == true && checkheader2 == true) {
        storage[i] = byteIn;
     i++;

     }
     
    //if byteIn contains the first headerbyte, checkheader1 is set to true
     if (checkheader1 == false && byteIn == 0x5F) {
         checkheader1 = true;
     }
   

    //if the first headerbyte has been received, and byteIn contains the 
    //second headerbyte, checkheader 2 is set to true
      if(checkheader1 == true && byteIn == 0xAF) {
        checkheader2 = true;
      }
   
   //end of while serial.available loop
   }    
 //end of void serial.event 
 }

Result : Done Compiling !!!

/* Written by Venderbroeck. */
/*free to use, but a reference would be nice =) */

#include <LiquidCrystal.h>

 //Setting up LCD
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD interface pins
 
  //transistor on pin 9
 int speedsignal = 9;
 
  //Piezo on pin 10
 int piezo = 10;
 
 //LED on pin 8
 int egtled = 8; 
 
 //declaring storage array
  int storage[60];  //megadataframe[60]
 
 //declaring byteIn in which to temporarely store bytes recieved by
 //the serial connection.
 int byteIn = 0;
 
 //declaring bools for header recognition script
 bool checkheader1 = false;
 bool checkheader2 = false;
 
 //declaring trigger bool, used to trigger void loop script
 bool trigger = false; //frametrigger
 
 //counter for the loop filling the storage array with data from the MEGA
 int i = 1; 
 
 //Declaring display value vars
 int IATvalue = 0;
 int EGTvalue = 0;
 int AFRvalue = 0;
 int BOOSTvalue = 0;
 int SPEEDvalue = 0;
 //BOOST/VAC
 float rawval = 0; // Setup raw sensor value
 float boost = 0; // Setup boost value
 float vac = 0; // Setup vacuum value
 //AFR
 float rawvala = 0; // Setup raw afr sensor value
 float afr = 0; // Setup value for afr value 
 //EGT
 int rawvale = 0; // Setup raw egt sensor value
 int egt = 0; // Setup value for egt value
 //SPEED
 int rawspeedval = 0; // Setup raw egt sensor value
 int speedval = 0; // Setup value for egt value

 void setup() {
   {  
  pinMode(egtled, OUTPUT); //Define EGT high LED  
  pinMode(piezo, OUTPUT); //Define EGT high piezo   
  pinMode(speedsignal, OUTPUT); //Define speed signal switch  
 } 
         // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);

  lcd.setCursor(4,0); //set cursor to top left corner
  lcd.print("Volvo V70 R"); //print the text to the lcd
  lcd.setCursor(3,2); //set cursor to top left corner
  lcd.print("Custom tune by"); //print the text to the lcd
  lcd.setCursor(5,3); //set cursor to top left corner
  lcd.print("Avinitlarge"); //print the text to the lcd
  {
    delay(2000);  //change the delay to change how fast the boot up screen changes 
  }
   
 /*configuring lcd stuff*/
 
 lcd.begin(20, 4); // set the LCD's columns and rows
 
 // Setup static characters on the lcd
  lcd.setCursor(2,0);
  lcd.print("IAT:");
  lcd.setCursor(2,1);
  lcd.print("EGT:");
  lcd.setCursor(2,2);
  lcd.print("AFR:");
  lcd.setCursor(0,3);
  lcd.print("BOOST:");

 Serial.begin(9600); 

 }
 
void loop() {
  
   if (trigger == true) { 
     IATvalue = storage[1];
     EGTvalue = storage[2];
     AFRvalue = storage[3];
     BOOSTvalue = storage[4];
     SPEEDvalue = storage[5];

    /*add code here to values to lcd*/
//IAT Gauge start
  lcd.setCursor(7,0);
  lcd.print(IATvalue,1); // Prints the IAT figure
  lcd.print((char)178);
  lcd.print("C ");
//IAT Gauge end

//Speed Gauge start
  // some base calculations to get speed
  rawspeedval = (SPEEDvalue); // Calculate speed value from raw value for debugging
  speedval = (rawspeedval*(0.621371)); // Calculate afr from raw value ***(calculations need proving)***
// lcd.setCursor(7,2);
// lcd.print(afr,1); // Prints the speed figure
//AFR Gauge end
   if (speedval < 15) // set for temp for LED to switch on  
  {  
   digitalWrite(speedsignal, HIGH);  
  }  
  else    
  {  
   digitalWrite(speedsignal, LOW);  
  }  
//Speed Gauge end
  
//EGT Gauge start
  rawvale = (EGTvalue); // Calculate afr value from raw value for debugging
  egt = (rawvale*(4)); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,1);
  lcd.print(egt,1); // Prints the EGT figure
  lcd.print((char)178);
  lcd.print("C ");
//EGT Gauge end

//EGT LED warning start
 // if (egt > 800) // set for temp for LED to switch on  
//  {  
 //  digitalWrite(egtled, HIGH);  
 // }  
 // else    
 // {  
//   digitalWrite(egtled, LOW);  
//  }  
//EGT LED warning end

//EGT piezo warning start
   
  if(egt > 800)
   {
    // sound buzzer
  playBuzzer(piezo);
   }

  delay(100);
}



//EGT piezo warning end
  
  
//AFR Gauge start
  // some base calculations to get afr
  rawvala = (AFRvalue); // Calculate afr value from raw value for debugging
  afr = (rawvala*(0.03671875)+10); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,2);
  lcd.print(afr,1); // Prints the afr figure
//AFR Gauge end

//Boost gauge start
// some base calculations to get pressures
 rawval = (BOOSTvalue); // Read MAP sensor raw value on analog port 0
 //kpaval = (rawval*(0.004)/(0.022)+20); // Calculate kpa value from raw value for debugging
 boost = ((((rawval/255) + 0.04)/0.004)*0.145) - 14.528; // Calculate psi from raw value ***(calculations need proving)***


if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
  {
  lcd.setCursor(7,3);
  lcd.print(boost,1); // Prints the BOOST figure
  lcd.setCursor(11,3);
  lcd.print("psi "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'

  }

if (boost < 0)
  {
  lcd.setCursor(7,3);
  lcd.print(vac,1); // Prints the vacuum figure
  vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
  lcd.setCursor(11,3); 
  lcd.print("inHg"); // Changes the units to 'inHg' on the lcd
  
  }


//BOOST Gauge end
  
    /**/
     
    trigger = false; 
   }
 
void playBuzzer(int piezo)
{
  for(int i = 0; i < 3; ++i)
  {
    // alternate between two tones, one high and one low
    // at the same time alternate the blue and red LED flashing
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 400);          // play 400 Hz tone for 500 ms 
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
    
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 800);          // play 800Hz tone for 500ms
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
  }

  // Stop the buzzer
  noTone(piezo);
}

 void serialEvent() {
  //Run the while loop for as long as serial data is available.
  //Keep in mind the whole loop will iterate once for each incoming byte.
   while (Serial.available() ) {
    //reset byteIn variable. Might be redundant.
    byteIn = 0;
    //take byte out of the serial 3 buffer and store it.
    byteIn = Serial.read();

    /*the next if statements need to be ran in this specific order.
    They look for the header and store the MEGA dataframe in 'storage' for 
    later use by the nano.
    MEGA header = 5F AF
    MEGA footer = B4 64 */


    //If both the headerbytes have been recieved and i == 5,
    //the loop storing the body has allready been completed, so 
    //both checkheader triggers reset to false and i resets to 1
    //Also it will set the void loop trigger to true to run the script it contains.
      if (checkheader1 == true && checkheader2 == true && i == 5) {
       checkheader1 = false;
       checkheader2 = false;
       trigger = true;
       i = 1; 

     }

    //ERRORCHECK
    //If first headerbyte was recieved, and the second was not, 
    //and the byte stored isn't AF, something went 
    //wrong and checkheader1, and i both reset.
      if (checkheader1 == true && checkheader2 == false && byteIn != 0xAF) {
       checkheader1 = false;
       i = 1;
      }

    /*The actual part filling the array. Everytime the while(serial available())
    loop iterates, and the headertriggers are set true, and nothing was changed 
    above this will write the byte stored in byteIn to the proper place in storage. 
    Note that i is incremented here each iteration. When it reaches 5 (all bytes recieved)
    all triggers, including i are reset above in the next loop iteration. */
     if(checkheader1 == true && checkheader2 == true) {
        storage[i] = byteIn;
     i++;

     }
     
    //if byteIn contains the first headerbyte, checkheader1 is set to true
     if (checkheader1 == false && byteIn == 0x5F) {
         checkheader1 = true;
     }
   

    //if the first headerbyte has been received, and byteIn contains the 
    //second headerbyte, checkheader 2 is set to true
      if(checkheader1 == true && byteIn == 0xAF) {
        checkheader2 = true;
      }
   
   //end of while serial.available loop
   }    
 //end of void serial.event 
 }

You're missing curly braces, and apparently aren't familiar with the concept of them, judging by the code.

To be honest, Im not. I know very little, very new to this. I am trying to do as much as possible without asking for help, once Ive spent a couple of hours trying to figure out where I went wrong, then I ask.

Avinitlarge:
To be honest, Im not. I know very little, very new to this. I am trying to do as much as possible without asking for help, once Ive spent a couple of hours trying to figure out where I went wrong, then I ask.

There were some errors on your code.. I made some corrections and i posted it above.. i guess you didn't see that... :~ :~

You're missing curly braces, and apparently aren't familiar with the concept of them, judging by the code.

Missing them? There are useless ones all over the place.

Sticking in an extra curly brace when something fails to compile is NOT the solution. Use curly braces only where needed - to start and end a function and to start and end a block after an if statement, for loop, while statement, or do/while statement.

Get rid of ALL of the others.

Sorry, I didnt see it. Will give it a try, and report back, thank you :slight_smile:

PaulS:

You're missing curly braces, and apparently aren't familiar with the concept of them, judging by the code.

Missing them? There are useless ones all over the place.

Sticking in an extra curly brace when something fails to compile is NOT the solution. Use curly braces only where needed - to start and end a function and to start and end a block after an if statement, for loop, while statement, or do/while statement.

Get rid of ALL of the others.

If I knew which ones to remove, I would. Still trying to get the hang of programming. Its all new to me

Avinitlarge:
To be honest, Im not. I know very little, very new to this.

Here's a quick explanation, but you would be better off finding a tutorial online to get the full breadth of information.

Each left curly brace '{' (called the opening brace) needs an associated right curly brace '}' (called the closing brace). Any line of code between that is in the same block of code. Typically, these are only used after function implementations:

void setup()
{

}

if statements

if (someConditionIsTrue)
{

}

and loops

while (someConditionIsTrue)
{

}

Not only is your code missing braces, but it has extraneous pairs:

void setup() {
   {  
  pinMode(egtled, OUTPUT); //Define EGT high LED  
  pinMode(piezo, OUTPUT); //Define EGT high piezo   
  pinMode(speedsignal, OUTPUT); //Define speed signal switch  
 }

Notice two opening braces and one closing one. Anything within the first opening brace (next to setup()) will be part of the setup function, so the following opening brace, and its associated curly brace is pointless unless you know what you're doing with the scoping (you don't and it's so rare that I couldn't even think up an example where it would be used).

Yep, I did notice that, I've tidied it up a bit and it compiles. Does this look better?

/* Written by Venderbroeck. */
/*free to use, but a reference would be nice =) */

#include <LiquidCrystal.h>

 //Setting up LCD
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD interface pins
 
  //transistor on pin 9
 int speedsignal = 9;
 
  //Piezo on pin 10
 int piezo = 10;
 
 //LED on pin 8
 int egtled = 8; 
 
 //declaring storage array
  int storage[60];  //megadataframe[60]
 
 //declaring byteIn in which to temporarely store bytes recieved by
 //the serial connection.
 int byteIn = 0;
 
 //declaring bools for header recognition script
 bool checkheader1 = false;
 bool checkheader2 = false;
 
 //declaring trigger bool, used to trigger void loop script
 bool trigger = false; //frametrigger
 
 //counter for the loop filling the storage array with data from the MEGA
 int i = 1; 
 
 //Declaring display value vars
 int IATvalue = 0;
 int EGTvalue = 0;
 int AFRvalue = 0;
 int BOOSTvalue = 0;
 int SPEEDvalue = 0;
 //BOOST/VAC
 float rawval = 0; // Setup raw sensor value
 float boost = 0; // Setup boost value
 float vac = 0; // Setup vacuum value
 //AFR
 float rawvala = 0; // Setup raw afr sensor value
 float afr = 0; // Setup value for afr value 
 //EGT
 int rawvale = 0; // Setup raw egt sensor value
 int egt = 0; // Setup value for egt value
 //SPEED
 int rawspeedval = 0; // Setup raw egt sensor value
 int speedval = 0; // Setup value for egt value

 void setup() {
    
  pinMode(egtled, OUTPUT); //Define EGT high LED  
  pinMode(piezo, OUTPUT); //Define EGT high piezo   
  pinMode(speedsignal, OUTPUT); //Define speed signal switch  
 
         // set up the LCD's number of columns and rows:

  lcd.begin(20, 4);

  lcd.setCursor(4,0); //set cursor to top left corner
  lcd.print("Volvo V70 R"); //print the text to the lcd
  lcd.setCursor(3,2); //set cursor to top left corner
  lcd.print("Custom tune by"); //print the text to the lcd
  lcd.setCursor(5,3); //set cursor to top left corner
  lcd.print("Avinitlarge"); //print the text to the lcd
  
    delay(2000);  //change the delay to change how fast the boot up screen changes 
  
   
 /*configuring lcd stuff*/
 
 lcd.begin(20, 4); // set the LCD's columns and rows
 
 // Setup static characters on the lcd
  lcd.setCursor(2,0);
  lcd.print("IAT:");
  lcd.setCursor(2,1);
  lcd.print("EGT:");
  lcd.setCursor(2,2);
  lcd.print("AFR:");
  lcd.setCursor(0,3);
  lcd.print("BOOST:");

 Serial.begin(9600); 

 }
 
void loop() {
  
   if (trigger == true) { 
     IATvalue = storage[1];
     EGTvalue = storage[2];
     AFRvalue = storage[3];
     BOOSTvalue = storage[4];
     SPEEDvalue = storage[5];

    /*add code here to values to lcd*/
//IAT Gauge start
  lcd.setCursor(7,0);
  lcd.print(IATvalue,1); // Prints the IAT figure
  lcd.print((char)178);
  lcd.print("C ");
//IAT Gauge end

//Speed Gauge start
  // some base calculations to get speed
  rawspeedval = (SPEEDvalue); // Calculate speed value from raw value for debugging
  speedval = (rawspeedval*(0.621371)); // Calculate afr from raw value ***(calculations need proving)***
   if (speedval < 15) // set for temp for LED to switch on  
  {  
   digitalWrite(speedsignal, HIGH);  
  }  
  else    
  {  
   digitalWrite(speedsignal, LOW);  
  }  
//Speed Gauge end
  
//EGT Gauge start
  rawvale = (EGTvalue); // Calculate afr value from raw value for debugging
  egt = (rawvale*(4)); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,1);
  lcd.print(egt,1); // Prints the EGT figure
  lcd.print((char)178);
  lcd.print("C ");
//EGT Gauge end

//EGT piezo warning start   
  if(egt > 800)
   {
    // sound buzzer
  playBuzzer(piezo);
  }

  delay(100);
  }
//EGT piezo warning end
    
//AFR Gauge start
  // some base calculations to get afr
  rawvala = (AFRvalue); // Calculate afr value from raw value for debugging
  afr = (rawvala*(0.03671875)+10); // Calculate afr from raw value ***(calculations need proving)***
  lcd.setCursor(7,2);
  lcd.print(afr,1); // Prints the afr figure
//AFR Gauge end

//Boost gauge start
// some base calculations to get pressures
 rawval = (BOOSTvalue); // Read MAP sensor raw value on analog port 0
 boost = ((((rawval/255) + 0.04)/0.004)*0.145) - 14.528; // Calculate psi from raw value ***(calculations need proving)***


if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
  {
  lcd.setCursor(7,3);
  lcd.print(boost,1); // Prints the BOOST figure
  lcd.setCursor(11,3);
  lcd.print("psi "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
  }

if (boost < 0)
  {
  lcd.setCursor(7,3);
  lcd.print(vac,1); // Prints the vacuum figure
  vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
  lcd.setCursor(11,3); 
  lcd.print("inHg"); // Changes the units to 'inHg' on the lcd
  }


//BOOST Gauge end
  
    /**/
     
    trigger = false; 
   }
   void playBuzzer(int piezo)
{
  for(int i = 0; i < 3; ++i)
  {
    // alternate between two tones, one high and one low
    // at the same time alternate the blue and red LED flashing
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 400);          // play 400 Hz tone for 500 ms 
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
    
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 800);          // play 800Hz tone for 500ms
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
  }

  // Stop the buzzer
  noTone(piezo);

 }

 void serialEvent() {
  //Run the while loop for as long as serial data is available.
  //Keep in mind the whole loop will iterate once for each incoming byte.
   while (Serial.available() ) {
    //reset byteIn variable. Might be redundant.
    byteIn = 0;
    //take byte out of the serial 3 buffer and store it.
    byteIn = Serial.read();

    /*the next if statements need to be ran in this specific order.
    They look for the header and store the MEGA dataframe in 'storage' for 
    later use by the nano.
    MEGA header = 5F AF
    MEGA footer = B4 64 */


    //If both the headerbytes have been recieved and i == 5,
    //the loop storing the body has allready been completed, so 
    //both checkheader triggers reset to false and i resets to 1
    //Also it will set the void loop trigger to true to run the script it contains.
      if (checkheader1 == true && checkheader2 == true && i == 5) {
       checkheader1 = false;
       checkheader2 = false;
       trigger = true;
       i = 1; 

     }

    //ERRORCHECK
    //If first headerbyte was recieved, and the second was not, 
    //and the byte stored isn't AF, something went 
    //wrong and checkheader1, and i both reset.
      if (checkheader1 == true && checkheader2 == false && byteIn != 0xAF) {
       checkheader1 = false;
       i = 1;
      }

    /*The actual part filling the array. Everytime the while(serial available())
    loop iterates, and the headertriggers are set true, and nothing was changed 
    above this will write the byte stored in byteIn to the proper place in storage. 
    Note that i is incremented here each iteration. When it reaches 5 (all bytes recieved)
    all triggers, including i are reset above in the next loop iteration. */
     if(checkheader1 == true && checkheader2 == true) {
        storage[i] = byteIn;
     i++;

     }
     
    //if byteIn contains the first headerbyte, checkheader1 is set to true
     if (checkheader1 == false && byteIn == 0x5F) {
         checkheader1 = true;
     }
   

    //if the first headerbyte has been received, and byteIn contains the 
    //second headerbyte, checkheader 2 is set to true
      if(checkheader1 == true && byteIn == 0xAF) {
        checkheader2 = true;
      }
   
   //end of while serial.available loop
   }    
 //end of void serial.event 
 }

Avinitlarge:
Yep, I did notice that, I've tidied it up a bit and it compiles. Does this look better?

/* Written by Venderbroeck. */

/*free to use, but a reference would be nice =) */

#include <LiquidCrystal.h>

//Setting up LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD interface pins

//transistor on pin 9
int speedsignal = 9;

//Piezo on pin 10
int piezo = 10;

//LED on pin 8
int egtled = 8;

//declaring storage array
  int storage[60];  //megadataframe[60]

//declaring byteIn in which to temporarely store bytes recieved by
//the serial connection.
int byteIn = 0;

//declaring bools for header recognition script
bool checkheader1 = false;
bool checkheader2 = false;

//declaring trigger bool, used to trigger void loop script
bool trigger = false; //frametrigger

//counter for the loop filling the storage array with data from the MEGA
int i = 1;

//Declaring display value vars
int IATvalue = 0;
int EGTvalue = 0;
int AFRvalue = 0;
int BOOSTvalue = 0;
int SPEEDvalue = 0;
//BOOST/VAC
float rawval = 0; // Setup raw sensor value
float boost = 0; // Setup boost value
float vac = 0; // Setup vacuum value
//AFR
float rawvala = 0; // Setup raw afr sensor value
float afr = 0; // Setup value for afr value
//EGT
int rawvale = 0; // Setup raw egt sensor value
int egt = 0; // Setup value for egt value
//SPEED
int rawspeedval = 0; // Setup raw egt sensor value
int speedval = 0; // Setup value for egt value

void setup() {
   
  pinMode(egtled, OUTPUT); //Define EGT high LED 
  pinMode(piezo, OUTPUT); //Define EGT high piezo   
  pinMode(speedsignal, OUTPUT); //Define speed signal switch

// set up the LCD's number of columns and rows:

lcd.begin(20, 4);

lcd.setCursor(4,0); //set cursor to top left corner
  lcd.print("Volvo V70 R"); //print the text to the lcd
  lcd.setCursor(3,2); //set cursor to top left corner
  lcd.print("Custom tune by"); //print the text to the lcd
  lcd.setCursor(5,3); //set cursor to top left corner
  lcd.print("Avinitlarge"); //print the text to the lcd
 
    delay(2000);  //change the delay to change how fast the boot up screen changes
 
   
/configuring lcd stuff/

lcd.begin(20, 4); // set the LCD's columns and rows

// Setup static characters on the lcd
  lcd.setCursor(2,0);
  lcd.print("IAT:");
  lcd.setCursor(2,1);
  lcd.print("EGT:");
  lcd.setCursor(2,2);
  lcd.print("AFR:");
  lcd.setCursor(0,3);
  lcd.print("BOOST:");

Serial.begin(9600);

}

void loop() {
 
   if (trigger == true) {
     IATvalue = storage[1];
     EGTvalue = storage[2];
     AFRvalue = storage[3];
     BOOSTvalue = storage[4];
     SPEEDvalue = storage[5];

/add code here to values to lcd/
//IAT Gauge start
  lcd.setCursor(7,0);
  lcd.print(IATvalue,1); // Prints the IAT figure
  lcd.print((char)178);
  lcd.print("C ");
//IAT Gauge end

//Speed Gauge start
  // some base calculations to get speed
  rawspeedval = (SPEEDvalue); // Calculate speed value from raw value for debugging
  speedval = (rawspeedval*(0.621371)); // Calculate afr from raw value (calculations need proving)
   if (speedval < 15) // set for temp for LED to switch on 
  { 
   digitalWrite(speedsignal, HIGH); 
  } 
  else   
  { 
   digitalWrite(speedsignal, LOW); 
  } 
//Speed Gauge end
 
//EGT Gauge start
  rawvale = (EGTvalue); // Calculate afr value from raw value for debugging
  egt = (rawvale*(4)); // Calculate afr from raw value (calculations need proving)
  lcd.setCursor(7,1);
  lcd.print(egt,1); // Prints the EGT figure
  lcd.print((char)178);
  lcd.print("C ");
//EGT Gauge end

//EGT piezo warning start   
  if(egt > 800)
   {
    // sound buzzer
  playBuzzer(piezo);
  }

delay(100);
  }
//EGT piezo warning end
   
//AFR Gauge start
  // some base calculations to get afr
  rawvala = (AFRvalue); // Calculate afr value from raw value for debugging
  afr = (rawvala*(0.03671875)+10); // Calculate afr from raw value (calculations need proving)
  lcd.setCursor(7,2);
  lcd.print(afr,1); // Prints the afr figure
//AFR Gauge end

//Boost gauge start
// some base calculations to get pressures
rawval = (BOOSTvalue); // Read MAP sensor raw value on analog port 0
boost = ((((rawval/255) + 0.04)/0.004)*0.145) - 14.528; // Calculate psi from raw value (calculations need proving)

if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
  {
  lcd.setCursor(7,3);
  lcd.print(boost,1); // Prints the BOOST figure
  lcd.setCursor(11,3);
  lcd.print("psi "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
  }

if (boost < 0)
  {
  lcd.setCursor(7,3);
  lcd.print(vac,1); // Prints the vacuum figure
  vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
  lcd.setCursor(11,3);
  lcd.print("inHg"); // Changes the units to 'inHg' on the lcd
  }

//BOOST Gauge end
 
    /**/
     
    trigger = false;
   }
   void playBuzzer(int piezo)
{
  for(int i = 0; i < 3; ++i)
  {
    // alternate between two tones, one high and one low
    // at the same time alternate the blue and red LED flashing
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 400);          // play 400 Hz tone for 500 ms
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
   
    digitalWrite(egtled, HIGH);   // LED on
    tone(piezo, 800);          // play 800Hz tone for 500ms
    delay(500);
    digitalWrite(egtled, LOW);    // LED off
  }

// Stop the buzzer
  noTone(piezo);

}

void serialEvent() {
  //Run the while loop for as long as serial data is available.
  //Keep in mind the whole loop will iterate once for each incoming byte.
   while (Serial.available() ) {
    //reset byteIn variable. Might be redundant.
    byteIn = 0;
    //take byte out of the serial 3 buffer and store it.
    byteIn = Serial.read();

/*the next if statements need to be ran in this specific order.
    They look for the header and store the MEGA dataframe in 'storage' for
    later use by the nano.
    MEGA header = 5F AF
    MEGA footer = B4 64 */

//If both the headerbytes have been recieved and i == 5,
    //the loop storing the body has allready been completed, so
    //both checkheader triggers reset to false and i resets to 1
    //Also it will set the void loop trigger to true to run the script it contains.
      if (checkheader1 == true && checkheader2 == true && i == 5) {
       checkheader1 = false;
       checkheader2 = false;
       trigger = true;
       i = 1;

}

//ERRORCHECK
    //If first headerbyte was recieved, and the second was not,
    //and the byte stored isn't AF, something went
    //wrong and checkheader1, and i both reset.
      if (checkheader1 == true && checkheader2 == false && byteIn != 0xAF) {
       checkheader1 = false;
       i = 1;
      }

/*The actual part filling the array. Everytime the while(serial available())
    loop iterates, and the headertriggers are set true, and nothing was changed
    above this will write the byte stored in byteIn to the proper place in storage.
    Note that i is incremented here each iteration. When it reaches 5 (all bytes recieved)
    all triggers, including i are reset above in the next loop iteration. */
     if(checkheader1 == true && checkheader2 == true) {
        storage[i] = byteIn;
     i++;

}
     
    //if byteIn contains the first headerbyte, checkheader1 is set to true
     if (checkheader1 == false && byteIn == 0x5F) {
         checkheader1 = true;
     }

//if the first headerbyte has been received, and byteIn contains the
    //second headerbyte, checkheader 2 is set to true
      if(checkheader1 == true && byteIn == 0xAF) {
        checkheader2 = true;
      }
   
   //end of while serial.available loop
   }   
//end of void serial.event
}

That's the code i posted back to you (the correct one )..
And i m sure you didn't even notice what was wrong with your code and it couldn't compile..

It is but I removed some curly brackets

Avinitlarge:
It is but I removed some curly brackets

That's not the reason why it compiles.. Because i posted back a code that already compiled..

Sorry, I saw the lines you moved, after that it compiled fine. I've also removed some of the extra curly brackets. I hate being a noob :blush:

You might want to spend some time going through simple examples.
You should know what every character in a sketch does and is for because just one wrong is a bug.