expected `}' at end of input

someone please help me with this error...

expected `}' at end of input
a function-definition is not allowed here before '{' token

#include <LiquidCrystal.h>
#include <MAX6675.h>

#define swStart 4
#define swStop  2
#define stbyMode A4
#define onMode A5
#define heater 3
#define CS 11
#define SO 12
#define SCK 13

int units = 1;
float tempRead = 0.0;

MAX6675 temp(CS,SO,SCK,units);

LiquidCrystal lcd(10,9,5,6,7,8);

uint8_t degree[8] = {140,146,146,140,128,128,128,128};

int ctrlStart;
int ctrlStop;
int onState;
long previousMillis;
long currentMillis;
long timeSet=3000000;
long timeCount;
int tempSet=250;
int processStart = LOW;

void setup()
{
  
 { Serial.begin(9600);
  lcd.begin(16,2);
  
  pinMode(swStart, INPUT);
  pinMode(swStop,INPUT);
  pinMode(onMode,OUTPUT);
  pinMode(stbyMode,OUTPUT);
  pinMode(heater,OUTPUT);
  
  lcd.createChar(0,degree);
  lcd.setCursor(0,0);
  lcd.print("Gula Melaka R11");
  delay(2000);
  lcd.clear();
  lcd.print("Heater System");
  
}

void loop()

  {
  while(Serial.avaiable()> 0)
  {
    int tempVal = Serial.parseInt();
    int timeVal = Serial.parseInt();
    if (Serial.read() == '\r')
    {
    tempSet = constrain(tempVal, 50, 350);
    timeSet = constrain(timeVal, 10, 99);
    Serial.print("TempSet degC: ");
    Serial.println(tempSet);
    Serial.print("TimeSet Mins: ");
    Serial.println(timeSet);
    timeSet = timeSet * 60000;
    }
  }
  
   ctrlStop = digitalRead(swStop);
   ctrlStart = digitalRead(swStart);
   if(ctrlStop == LOW && ctrlStart == HIGH)
  {
    digitalWrite(onMode, LOW);
    digitalWrite(stbyMode, HIGH);
    lcd.setCursor(0,1);
    lcd.print("Stop ");
    onState = LOW;
    digitalWrite(heater, LOW);
  }
  else if (ctrlStop == HIGH && ctrlStart == LOW)
  {
    digitalWrite(onMode,HIGH);
    digitalWrite(stbyMode,LOW);
    lcd.setCursor(0,0);
    lcd.clear();
    lcd.print("Set:");
    lcd.print(tempSet);
    lcd.write((byte)0);
    lcd.print("C");
    lcd.setCursor(0,1);
    lcd.print("Start");
    onState = HIGH;
    digitalWrite(heater, HIGH);
    processStart = HIGH;
  }
  
  if(onState == HIGH)
  {
    tempRead = temp.read_temp(); 
    if(tempRead < 0)
   {
    Serial.print("Thermocouple Error");
    Serial.println(tempRead);
    lcd.setCursor(7,1);
    lcd.print("T:");
    lcd.print("Error");
    digitalWrite(heater,LOW);
   }
   else
   {
    Serial.print("Current Temperature");
    Serial.println(tempRead);
    lcd.setCursor(7,1);
    lcd.print("T:");
    lcd.print(tempRead);
    lcd.write((byte)0);
    lcd.print("C");
    if(tempSet < tempRead && processStart == HIGH)
    
   {
      previousMillis = millis();
      processStart = LOW;
   }
   
   else if(tempSet < tempRead)
 {  
     currentMillis = millis();
     timeCount = (currentMillis - previousMillis)/60000;
     Serial.println(timeCount);
     lcd.setCursor(10,0);
     lcd.print("M:");
     lcd.print(timeCount);
     if(currentMillis - previousMillis > timeSet)
     
  {
  onState=LOW;
   }
   
   else
   {
    digitalWrite(heater,LOW);
    digitalWrite(onMode,LOW);
   }
 }
 else
 {
   digitalWrite(onMode, HIGH);
   digitalWrite(heater,LOW)
 }
   }
   
   delay(300);
  }
  else if(onState == LOW)
  {
    digitalWrite(heater,LOW);
    digitalWrite(onMode,LOW);
    digitalWrite(stbyMode,HIGH);
    lcd.setCursor(0,0);
    lcd.print("Heater System   ");
    lcd.setCursor(0,1);
    lcd.print("Stop");
  }
  
}

Why do you have an opening brace on this statement?

 { Serial.begin(9600);

Pete

el_supremo:
Why do you have an opening brace on this statement?

 { Serial.begin(9600);

Pete

THANKS PETE!....now i get different error

'class HardwareSerial' has no member named 'avaiable'

i think with this line

void loop()

  {
  while (Serial.avaiable()> 0)
  {
    int tempVal = Serial.parseInt();
    int timeVal = Serial.parseInt();
    if (Serial.read() == '\r')

avaiable isn't spelled correctly

Pete

problem solve..thanks to you..

quick question...i want to control a motor using a potentiometer..can i just define the value and add this line above it?

{
 potValue = analogRead(potPin);  
 motorValue = map(potValue, 0, 1023, 0, 255);
 analogWrite(motorPin, motorValue);  
 Serial.print("potentiometer = " );     
 Serial.print(potValue);
 Serial.print("\t motor = ");
 Serial.println(motorValue);
 delay(2);    
}

avaiable isn't spelled correctly

Sure it is. It's just that that isn't the name of the method in the HardwareSerial class. The name of the method is available().

PaulS:
Sure it is. It's just that that isn't the name of the method in the HardwareSerial class. The name of the method is available().

sorry..i really new into this this..is there anything wrong in this code?

cep3k:
sorry..i really new into this this..is there anything wrong in this code?

Does it compile?
Does it do what you want?

@cep3k: the code for the motor looks OK. Try it.

Pete

The code would benefit from a simpler code structure. I don't think I've ever seen such a long cascading if statement block before.