Help!

Arduino error reporting

sketch_oct18a:918: error: expected `}' at end of input

eventhough i closed all the loops, if i add extra brace the program is getting compiled but the last brace is not pointing to any previous brace :~ Help

It is impossible to help you without the code.

Please use code tags the next time you post code.

int h = A0;
int hh = 0;
int ii =0;
int arr[30]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int arrf[6]={0,0,0,0,0,0};
int z0=0;
int z1=0;
unsigned int z=0;
int counttt = 0;
int total0=0;
int total1=0;
int total2=0;
int total3=0;
int total4=0;
int total5=0;
int c1=0;
int c2=0;
int k=0;
int k1=0;
int k2=0;
int k3=0;
int k4=0;int k5=0;
int digiPin= A0;
int Hpin=A1;
int Lpin=A2;
int Spin=A3;
int sensorValue = 0;  // variable to store the value coming from the sensor
int SpinValue=0;
int poleAA=2;          //two hand poles
int poleBB=3;          //------"-------
int poleA=5;           //second hand poles 
int poleB=6;           //------"------- 

unsigned int n=0;


void setup()
{
  Serial.begin(9600);
  pinMode(poleA, OUTPUT);
  pinMode(poleB, OUTPUT); 
  pinMode(poleAA, OUTPUT);
  pinMode(poleBB, OUTPUT); 
  pinMode(Hpin, OUTPUT); 
  digitalWrite(Hpin, HIGH);
  pinMode(Lpin, OUTPUT); 
  digitalWrite(Lpin, LOW);  
  
  
}

#define ABhigh PORTD = PORTD | B00001100;
#define Ahigh PORTD = PORTD | B00000100;
#define Alow PORTD = PORTD & B11111011;
#define Bhigh PORTD = PORTD | B00001000;
#define Blow PORTD = PORTD & B11110111;
#define ABlow PORTD = PORTD & B11110011;
#define AlowBhigh PORTD = (PORTD & B11111011) | B00001000;
#define BlowAhigh PORTD = (PORTD & B11110111) | B00000100;


void loop()
{
  int scounter=0, d=0, r=0, R=0;
  
  for(int counter=0; counter<2160;)
  {
    int M=0, H=0, S=0;
    //Printing counter value as current time in watch
    M=counter/3;
    H=M/60;
    M=M-(H*60);
    Serial.println("");
  Serial.print("time: \t");      
  Serial.print(H);
  Serial.print(" : ");
  Serial.println(M);
    for(int i=1; i<10; i++)
    {
      int A=0, B=0, J=0, K=0;
      int high[32]={0}, low[32]={0};
      //int signal[7][6]={0}, TIME[7]={0};
      //char CHECK[6][5]={""};
      int h=0, m=0, s=0, input=0, sinput=0, c=0, b=0, y=0, e=0, del=0;
  Serial.print(i);
  Serial.print("-");
      SpinValue = digitalRead(Spin);          //read ldr value     
      Serial.print(SpinValue);
      Serial.print("\t");
    if(SpinValue==1)
    {  c2=1;
 if(c2==1)
{ 
 while(ii<31)
 {
  if(c1==1)
{
  switch (total0){
    case 14:arrf[0]=1;total0=0;k=1;break;
    case 12:arrf[0]=2;total0=0;k=1;break;
    case 9:arrf[0]=3;total0=0;k=1;break;
    case 5:arrf[0]=4;total0=0;k=1;break;
    case 0:arrf[0]=5;total0=0;k=1;break;
    case 1:arrf[0]=6;total0=0;k=1;break;
    case 3:arrf[0]=7;total0=0;k=1;break;
    case 6:arrf[0]=8;total0=0;k=1;break;
    case 10:arrf[0]=9;total0=0;k=1;break;
    case 15:arrf[0]=0;total0=0;k=1;break;
    }


  switch (total1){
    case 14:arrf[1]=1;total1=0;k1=1;break;
    case 12:arrf[1]=2;total1=0;k1=1;break;
    case 9:arrf[1]=3;total1=0;k1=1;break;
    case 5:arrf[1]=4;total1=0;k1=1;break;
    case 0:arrf[1]=5;total1=0;k1=1;break;
    case 1:arrf[1]=6;total1=0;k1=1;break;
    case 3:arrf[1]=7;total1=0;k1=1;break;
    case 6:arrf[1]=8;total1=0;k1=1;break;
    case 10:arrf[1]=9;total1=0;k1=1;break;
    case 15:arrf[1]=0;total1=0;k1=1;break;
    }



 switch (total2){
    case 14:arrf[2]=1;total2=0;k2=1;break;
    case 12:arrf[2]=2;total2=0;k2=1;break;
    case 9:arrf[2]=3;total2=0;k2=1;break;
    case 5:arrf[2]=4;total2=0;k2=1;break;
    case 0:arrf[2]=5;total2=0;k2=1;break;
    case 1:arrf[2]=6;total2=0;k2=1;break;
    case 3:arrf[2]=7;total2=0;k2=1;break;
    case 6:arrf[2]=8;total2=0;k2=1;break;
    case 10:arrf[2]=9;total2=0;k2=1;break;
    case 15:arrf[2]=0;total2=0;k2=1;break;
    }



 switch (total3){
    case 14:arrf[3]=1;total3=0;k3=1;break;
    case 12:arrf[3]=2;total3=0;k3=1;break;
    case 9:arrf[3]=3;total3=0;k3=1;break;
    case 5:arrf[3]=4;total3=0;k3=1;break;
    case 0:arrf[3]=5;total3=0;k3=1;break;
    case 1:arrf[3]=6;total3=0;k3=1;break;
    case 3:arrf[3]=7;total3=0;k3=1;break;
    case 6:arrf[3]=8;total3=0;k3=1;break;
    case 10:arrf[3]=9;total3=0;k3=1;break;
    case 15:arrf[3]=0;total3=0;k3=1;break;
    }



 switch (total4){
    case 14:arrf[4]=1;total4=0;k4=1;break;
    case 12:arrf[4]=2;total4=0;k4=1;break;
    case 9:arrf[4]=3;total4=0;k4=1;break;
    case 5:arrf[4]=4;total4=0;k4=1;break;
    case 0:arrf[4]=5;total4=0;k4=1;break;
    case 1:arrf[4]=6;total4=0;k4=1;break;
    case 3:arrf[4]=7;total4=0;k4=1;break;
    case 6:arrf[4]=8;total4=0;k4=1;break;
    case 10:arrf[4]=9;total4=0;k4=1;break;
    case 15:arrf[4]=0;total4=0;k4=1;break;
    }

  
  
   switch (total5){
    case 14:arrf[5]=1;total5=0;k5=1;break;
    case 12:arrf[5]=2;total5=0;k5=1;break;
    case 9:arrf[5]=3;total5=0;k5=1;break;
    case 5:arrf[5]=4;total5=0;k5=1;break;
    case 0:arrf[5]=5;total5=0;k5=1;break;
    case 1:arrf[5]=6;total5=0;k5=1;break;
    case 3:arrf[5]=7;total5=0;k5=1;break;
    case 6:arrf[5]=8;total5=0;k5=1;break;
    case 10:arrf[5]=9;total5=0;k5=1;break;
    case 15:arrf[5]=0;total5=0;k5=1;break;
    }
    c1=0;
}
  
  
 
  hh=analogRead(h);

  if(hh==0)
  {
    counttt++;
  }
  else{counttt=0;}
  
  if(hh>90)
  {
  z0++;
  //Serial.print("\t  \t");
  //Serial.print(hh);
  //Serial.print("\n");
  }
  else{
  z1++;  
  //Serial.print(hh);
  //Serial.print("\n");}

  if((z1>8)&&(z0>0 && z0<5)&&(counttt>2))  //DOT loop
  {
    Serial.print("Dot  \n");
    arr[ii]=0;
    ii++;
    z1=0;
    z0=0;
    y++;
    counttt=0;
    del+=arr[i];
  }
  
  if((z1>8)&&(z0>4 && z0<14)&&(counttt>2)) //dash loop
  {
    Serial.print("Dash  \n");
    arr[ii]=1;
    ii++;
    z1=0;
    z0=0;
    counttt=0;
    del+=arr[i];
    
  }

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

if(ii == 30)
  {
    for(int kk=0; kk<31; kk++)
    {
      Serial.print(arr[kk]);
      Serial.print("\t");
    }
    
    Serial.print("\n");
    
    for(int s = 0; s<5; s++)
    {
      total0=total0+((arr[s])*(s+1));
    }
    Serial.print("\n");
    Serial.print(total0);
    
    
    for(int s1 = 5; s1<10; s1++)
    {
      total1=total1+((arr[s1])*(s1-4));
    }
    Serial.print("\n");
    Serial.print(total1);
    
    
    for(int s2 = 10; s2<15; s2++)
    {
      total2=total2+((arr[s2])*(s2-9));
    }
    Serial.print("\n");
    Serial.print(total2);
    
    
    for(int s3 = 15; s3<20; s3++)
    {
      total3=total3+((arr[s3])*(s3-14));
    }
    Serial.print("\n");
    Serial.print(total3);
    
    
    for(int s4 = 20; s4<25; s4++)
    {
      total4=total4+((arr[s4])*(s4-19));
    }
    Serial.print("\n");
    Serial.print(total4);
    
    
    for(int s5 = 25; s5<30; s5++)
    {
      total5=total5+((arr[s5])*(s5-24));
    }
    Serial.print("\n");
    Serial.print(total5);
    Serial.print("\n");
    Serial.print("\n");
    
    
    c1=1;    
    i=0;
    Serial.print("\n");
    
  } //ii==30 loop end
delay(5);
z++;
if(z>=10000)
{
  break;
}
if((k==1)&&(k1==1)&&(k2==1)&&(k3==1)&&(k4==1)&&(k5==1))
{
 /* for(int s6=0; s6<6; s6++)
  {
    Serial.print(arrf[s6]);
    Serial.print("\t");
  }*/
   h=arrf[0]*10+arrf[1];          //convert the time array into time in terms of h, m and s
  m=arrf[2]*10+arrf[3];
  s=arrf[4]*10+arrf[5];
  
  Serial.print("\n");
  k=0;k1=0;k2=0;k3=0;k4=0;k5=0;
}

 Serial.println("");
  Serial.println("********FINAL TIME*************");      
  Serial.print(h);
  Serial.print(" : ");
  Serial.print(m);
  Serial.print(" : ");
  Serial.print(s);
             if(h==12)      //convert 12 into 0 for hrs (we are using only 12hr format now)
           {
             h=0;
           }
       
            
           
     s=(s+1)/2;           //identify the odd inputs given to the second hand, and make it the next even number
     s=s*2;
     e=s%2;
     
      if(s<20)          //for different inputs of second hand, give the require number of extra pulses to the minute hand (1 pulse for every 20 seconds)
                        //also, calculate the delta input given to the watch to reach final time
      {
      input=(180*h)+(3*m);
      input=input-counter;
      }
      if(s>=20 && s<40)
      {
      input=(180*h)+(3*m)+1;
      input=input-counter;
      }
      if(s>=40)
      {
      input=(180*h)+(3*m)+2;
      input=input-counter;
      }
            Serial.println("");
            Serial.print("s=");
            Serial.println(s);
            sinput=s-scounter;      //calculating input for second hand           
            if(sinput<0)
            {
             sinput=60+sinput;
            }  
      c2=0;            
 } } //c2 loop end
    
    Serial.println("");
Serial.print("y");
Serial.println(y);
            R=0;
            if (y>0 || z==10000)
            {  
              r=0;
              R=1;            
               del=(z+del)/1000;
               Serial.println("");
               Serial.print("del=");
               Serial.println(del);              
              sinput=del;
              input=0;              
              if (sinput>=20 || (scounter+del)>=60)
              {
                input=1;
              }
            }

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

  //define cases to calculate the shortest path based on time taken by forward and reverse speeds.
           // Basically, the clock is split into 8hrs forward and 4 hrs backward
           if ((input>=0) && (input<=1440))          //case 1, if the final  time is under next 8 hrs in forward direction
           {
             b=1;
             c=input;
           }
           if ((input>-2160) && (input<-720))        //case 2, if the final  time is under next 8 hrs in forward direction, with 12 O'clock in the way
           {
             b=1;
             c=2160+input;
           }
           if ((input<0) && (input >= -720))        //case 3, if the final  time is under previous 4 hrs in reverse direction
          {
            b=2;
            c=-input;
          }
           if ((input>1440) && (input < 2160))      //case 4, if the final  time is under previous 4 hrs in reverse direction, with 12 O'clock in the way
          {
            b=2;
            c=2160-input;  
          }
          
          if(b==1)  //forward motion, case 1 & 2
          {
            
            int a=0;
            while(a<c)
            {          
              switch (d)          //as d changes from 0 and 1 alternatingly case 0&1 are executed alternatingly 
              {
                case 0:      //pole A 
                AlowBhigh    
                delayMicroseconds(2000);
                ABhigh
                delayMicroseconds(5812);
                a++;
                counter++;      
                if(counter==2160)    //reset counter back to 0, if crossed 12hrs
                {
                  counter=0;
                }
                break;               
                
                case 1:     
                BlowAhigh    //pole B
                delayMicroseconds(2000);
                ABhigh
                delayMicroseconds(5812);
                a++;
                counter++;
                if(counter==2160)
                {
                  counter=0;
                } 
                break;
              }
              n++;                //n is unigned numbebr which would keep on increasing, making it odd and even alternatingly 
              d=n%2;              //this will make d's value 0 and 1 alternatingly
            }            
          }
          
          if(b==2)           //reverse motion, case 3 & 4
          {

            int a=0;
            while(a<c)
            {          
              switch (d)
              {
                case 0:
               Alow
               delayMicroseconds(500);
               Ahigh
               delayMicroseconds(400);
               Alow
               delayMicroseconds(500);
               BlowAhigh
               delayMicroseconds(1600);
               AlowBhigh
               delayMicroseconds(1100);
               ABhigh  
               delayMicroseconds(8000);
               a++;
               counter--;
               if(counter==-1)        
               {
                 counter=2159;        //reset the counter to max if counter becomes less than 0
               }
                break;               
               
               case 1:
               Blow
       delayMicroseconds(500);
       Bhigh
       delayMicroseconds(400);
       Blow
       delayMicroseconds(500);
       AlowBhigh
       delayMicroseconds(1600);
       BlowAhigh
       delayMicroseconds(1100);
       ABhigh  
       delayMicroseconds(8000);
               a++;
               counter--;
               if(counter==-1)
               {
                 counter=2159;
               }      
                break;
              }
              n++;
              d=n%2;            
            }            
          }
          
            for ( int w1= 0; w1<sinput;)      //forward motion of second hand
         {
          
          digitalWrite(poleA, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleA,HIGH);
          digitalWrite(poleB,HIGH);
          delay(20);
          w1++;
          scounter++;                      
          digitalWrite(poleB, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleB, HIGH);
          digitalWrite(poleA, HIGH);
          delay(20);
          w1++;
          scounter++;
          if (scounter==60)
          {
            scounter=0;
          }
          }
          delay(1000);
          
     scounter=(scounter+1)/2;           //identify the odd inputs given to the second hand, and make it the next even number
     scounter=scounter*2;
     e=scounter%2;
     
      if(scounter<20)          //for different inputs of second hand, give the require number of extra pulses to the minute hand (1 pulse for every 20 seconds)
      {                  //also, calculate the delta input given to the watch to reach final time      
      i=scounter/2;      //final value of i to continue the loop from
      }
      if(scounter>=20 && s<40)
      {
      i=(scounter-20)/2;
      }
      if(scounter>=40)
      {
      i=(scounter-40)/2;
      }
          
          if (e==1)       //if second hand input is odd, move to the next even input and wait for one second
          
          {
            delay(1000);
          }  
          
          
        
    } //spinvalue == 1 loop end
    
    
    
     if(R==0)
        {
          digitalWrite(poleA, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleB, HIGH);
          digitalWrite(poleA, HIGH);   
          delay(997);
          delayMicroseconds(800);
          scounter++;     
        
          digitalWrite(poleB, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleB, HIGH);
          digitalWrite(poleA, HIGH);
          delay(997);
          delayMicroseconds(800);
          scounter++;
          if (scounter==60)
          {
            scounter=0;
          }
        }
        
        if(R==1)
        {
          delay(797);
          digitalWrite(poleA, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleB, HIGH);
          digitalWrite(poleA, HIGH);   
          delay(200);
          delayMicroseconds(800);
          scounter++;     
        
          digitalWrite(poleB, LOW);
          delayMicroseconds(2200);
          digitalWrite(poleB, HIGH);
          digitalWrite(poleA, HIGH);
          delay(200);
          delayMicroseconds(800);
          delay(797);
          r++;
          if(r>10)
          {
            R=0;
          }
          scounter++;
          if (scounter==60)
          {
            scounter=0;
          }
        }
          
    
                
    } //i=10 loop end
//-----------------------------------------------------------------------------    
    //19th tick of the second hand
      digitalWrite(poleA, LOW);
      delayMicroseconds(2200);
      digitalWrite(poleB, HIGH);
      digitalWrite(poleA, HIGH);   
      delay(997);
      delayMicroseconds(800); 
      scounter++;
         
      //normal minute hand tick, synchronised with the 20th second hand tick
      // case d=1 and d=2 represent the opposite poles
      switch (d)
    {
      case 0:      
      AlowBhigh //digitalWrite(poleB, LOW);
      delayMicroseconds(2000);
      ABhigh
      delay(50);
      digitalWrite(poleB, LOW);
      delayMicroseconds(2200);
      digitalWrite(poleB, HIGH);
      digitalWrite(poleA, HIGH);
      delay(945);
      delayMicroseconds(300);
      break;
         
      case 1:         
      BlowAhigh //digitalWrite(poleA, LOW);
      delayMicroseconds(2000);
      ABhigh
      delay(50);
      digitalWrite(poleB, LOW);
      delayMicroseconds(2200);
      digitalWrite(poleB, HIGH);
      digitalWrite(poleA, HIGH);
      delay(945);
      delayMicroseconds(300);
      break;
    }
    n++;
    d=n%2;    
    counter++;
    if(counter==2160)    //reset counter back to 0, if crossed 12hrs
      {
        counter=0;
      }
    
    scounter++;
      if (scounter==60)
      {
        scounter=0;
      }
  } /*counter 2160 loop end*/
}

Sorry it is too lengthy!! :~

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

You have a mismatched } there somewhere.

Check carefully for any ) when you should have }, and vice versa. In some fonts, it is easy to mistake.

It is probably a good idea to move all the #defines to the top.

Tools / Auto Format reveals you have some comments in the wrong place (or closing braces in the wrong place)…

      if(SpinValue==1)
      {  
        c2=1;
        if(c2==1)
        { 
          while(ii<31)
          {
            if(c1==1)
            {
...
        } //spinvalue == 1 loop end
...
      } //i=10 loop end
    for(int i=1; i<10; i++)
    {
...
    } /*counter 2160 loop end*/

prasanthreddyb: Arduino error reporting

sketch_oct18a:918: error: expected `}' at end of input

In what code?

Read this before posting a programming question

How to use this forum

              switch (d)          //as d changes from 0 and 1 alternatingly case 0&1 are executed alternatingly 
              {
                case 0:      //pole A 
                AlowBhigh    
                delayMicroseconds(2000);
                ABhigh
                delayMicroseconds(5812);
                a++;

Huh?

http://www.gammon.com.au/tips

Better read the whole thing.

               Alow
               delayMicroseconds(500);
               Ahigh
               delayMicroseconds(400);
               Alow
               delayMicroseconds(500);
               BlowAhigh
               delayMicroseconds(1600);
               AlowBhigh
               delayMicroseconds(1100);
               ABhigh  
               delayMicroseconds(8000);

This is complete nonsense, sorry. Google "C tutorial".

[quote author=Nick Gammon link=topic=194032.msg1433239#msg1433239 date=1382087724]

               Alow
               delayMicroseconds(500);
               Ahigh
               delayMicroseconds(400);
               Alow
               delayMicroseconds(500);
               BlowAhigh
               delayMicroseconds(1600);
               AlowBhigh
               delayMicroseconds(1100);
               ABhigh  
               delayMicroseconds(8000);

This is complete nonsense, sorry. Google "C tutorial". [/quote]

?? If you are talking about things like AlowBhigh, he did #define them...

#define BlowAhigh PORTD = (PORTD & B11110111) | B00000100;

Sorry it is too lengthy!!

You can do attachments. Then you can attach it as one file.

How to use this forum

If you are talking about things like AlowBhigh, he did #define them...

I strongly advise against this style of programming. It looks confusing. It looks like you forgot both the braces and the semicolon.

Reading your code shouldn't be like solving the Sunday crossword puzzle, where things are deliberately obscure.

  switch (total0){
    case 14:arrf[0]=1;total0=0;k=1;break;
    case 12:arrf[0]=2;total0=0;k=1;break;
    case 9:arrf[0]=3;total0=0;k=1;break;
    case 5:arrf[0]=4;total0=0;k=1;break;
    case 0:arrf[0]=5;total0=0;k=1;break;
    case 1:arrf[0]=6;total0=0;k=1;break;
    case 3:arrf[0]=7;total0=0;k=1;break;
    case 6:arrf[0]=8;total0=0;k=1;break;
    case 10:arrf[0]=9;total0=0;k=1;break;
    case 15:arrf[0]=0;total0=0;k=1;break;
    }

Also put one statement per line. And if you are setting total0 to 0, and k to 1, for every case, why not do that elsewhere?

if((k==1)&&(k1==1)&&(k2==1)&&(k3==1)&&(k4==1)&&(k5==1))

How about meaningful data names?

Here's a style guide:

http://www.gammon.com.au/forum/?id=12153#style