expected '}' at end of input

Hello, I'm new to this. I think that error could mean there's a mismatched bracket somewhere, but I can't figure out what's wrong. I'm using this TFT. I've been successfully been able to run this library without issues, but on this newer version (which has added graphical functionality I want), the error shows.

The example I'm running:

#include <SPI.h>
#include <TFT_ILI9163C.h>

/*
  Teensy3.x and Arduino's
  You are using 4 wire SPI here, so:
  MOSI:  11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  MISO:  12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  SCK:   13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
  ESP8266-----------------------------------
  Use:
  #define __CS  16  //(D0)
  #define __DC  5   //(D1)
  #define __RST 4   //(D2)

  SCLK:D5
  MOSI:D7
*/
#define __CS1 10
#define __DC 9
/*
  Teensy 3.x can use: 2,6,10,15,20,21,22,23
  Arduino's 8 bit: any
  DUE: check arduino site
  If you do not use reset, tie it to +3V3
*/


#if defined(TFT_ILI9163C_INSTANCES)
TFT_ILI9163C tft = TFT_ILI9163C(REDPCB_NEW, __CS1, 8, __DC);
#else
TFT_ILI9163C tft = TFT_ILI9163C(__CS1, 8, __DC);
#endif

void setup() {
  tft.begin();
  tft.print("hello World");
}

void loop(void) {
}

The error:

Arduino: 1.8.2 (Windows 8.1), Board: "Arduino/Genuino Uno"

basicSetup:42: error: expected '}' at end of input

 }

 ^

In file included from C:\Users\Towy\AppData\Local\Temp\arduino_modified_sketch_204873\basicSetup.ino:2:0:

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'void TFT_ILI9163C::drawArc(uint16_t, uint16_t, uint16_t, uint16_t, float, float, uint16_t)':

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:204:70: error: 'drawArcHelper' was not declared in this scope

       drawArcHelper(cx, cy, radius, thickness, 0, _arcAngleMax, color);

                                                                      ^

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:206:157: error: 'drawArcHelper' was not declared in this scope

       drawArcHelper(cx, cy, radius, thickness, start + (_arcAngleOffset / (float)360)*_arcAngleMax, end + (_arcAngleOffset / (float)360)*_arcAngleMax, color);

                                                                                                                                                             ^

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'virtual size_t TFT_ILI9163C::write(uint8_t)':

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:233:67: error: '_textWrite' was not declared in this scope

  virtual size_t  write(uint8_t b) { _textWrite((const char *)&b, 1); return 1;}

                                                                   ^

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'virtual size_t TFT_ILI9163C::write(const uint8_t*, size_t)':

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:234:98: error: '_textWrite' was not declared in this scope

  virtual size_t  write(const uint8_t *buffer, size_t size) {_textWrite((const char *)buffer, size); return size;}

                                                                                                  ^

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'void TFT_ILI9163C::enableCommandStream()':

C:\Users\Towy\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:354:34: error: a function-definition is not allowed here before '{' token

   __attribute__((always_inline)) { *rsport |= dcpinmask;//hi }

                                  ^

basicSetup:42: error: expected '}' at end of input

 }

 ^

C:\Users\Towy\AppData\Local\Temp\arduino_modified_sketch_204873\basicSetup.ino: At global scope:

basicSetup:42: error: expected unqualified-id at end of input

exit status 1
expected '}' at end of input

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

I would put a blank line after the closing bracket of loop() and hope that fixes it.

Blank lines did not work. I apologize, this is the error message. ( I mistakenly thought the error message was the only text I could immediately see. )

Arduino: 1.8.2 (Windows 8.1), Board: "Arduino/Genuino Uno"

basicSetup:42: error: expected '}' at end of input

 }

 ^

In file included from C:\Users\Abc\AppData\Local\Temp\arduino_modified_sketch_708842\basicSetup.ino:2:0:

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'void TFT_ILI9163C::drawArc(uint16_t, uint16_t, uint16_t, uint16_t, float, float, uint16_t)':

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:204:70: error: 'drawArcHelper' was not declared in this scope

       drawArcHelper(cx, cy, radius, thickness, 0, _arcAngleMax, color);

                                                                      ^

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:206:157: error: 'drawArcHelper' was not declared in this scope

       drawArcHelper(cx, cy, radius, thickness, start + (_arcAngleOffset / (float)360)*_arcAngleMax, end + (_arcAngleOffset / (float)360)*_arcAngleMax, color);

                                                                                                                                                             ^

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'virtual size_t TFT_ILI9163C::write(uint8_t)':

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:233:67: error: '_textWrite' was not declared in this scope

  virtual size_t  write(uint8_t b) { _textWrite((const char *)&b, 1); return 1;}

                                                                   ^

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'virtual size_t TFT_ILI9163C::write(const uint8_t*, size_t)':

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:234:98: error: '_textWrite' was not declared in this scope

  virtual size_t  write(const uint8_t *buffer, size_t size) {_textWrite((const char *)buffer, size); return size;}

                                                                                                  ^

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h: In member function 'void TFT_ILI9163C::enableCommandStream()':

C:\Users\Abc\Documents\Arduino\libraries\TFT_ILI9163C-1.0p8/TFT_ILI9163C.h:354:34: error: a function-definition is not allowed here before '{' token

   __attribute__((always_inline)) { *rsport |= dcpinmask;//hi }

                                  ^

basicSetup:42: error: expected '}' at end of input

 }

 ^

C:\Users\Abc\AppData\Local\Temp\arduino_modified_sketch_708842\basicSetup.ino: At global scope:

basicSetup:42: error: expected unqualified-id at end of input

exit status 1
expected '}' at end of input

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

When you encounter an error you should always scroll all the way up and deal with the errors from the top to the bottom of the output because often the later errors are caused by the earlier ones. That is the case here. Unfortunately there are some serious problems with that library that I believe would require some significant work to fix. Even the 1.0 release seems to have problems. There are also some minor, easy to fix bugs that have not been fixed which indicates to me that the library author doesn't do even the most minimal testing and won't take the time to merge simple bug fix contributions. I think it's the best idea to give up on using it and look for a higher quality library.

Thank you, I'll keep that in mind. I have tried other libraries, but I can't get them to work properly (display errors). My main goal is to be able to use a library I can use to display an image on the flash memory. I know image converters can convert to C code, but I dunno how to call that properly into the code.

Being fairly new to Arduino, I cannot claim to know very much.

I do notice that in your #if...else lines there are no {}. if normally needs them, but #if???

Fof

Try uninstalling your version 1.0-p8 of the library and instead try using the tip of the master branch:
https://github.com/sumotoy/TFT_ILI9163C/archive/master.zip
I believe that is considered version 0.9. It's quite outdated but that may be a good thing. You will need to install the Adafruit_GFX library and there may be some changes necessary in your code. See the included examples for details.

IamFof:
I do notice that in your #if...else lines there are no {}. if normally needs them, but #if???

No, it doesn't. See the "conditional inclusions" section of:
http://www.cplusplus.com/doc/tutorial/preprocessor/

Thanks, pert

I learn something new every day.

Fof

Yes, it's very important information. The preprocessor shouldn't be used frivolously but it's a very powerful tool.

pert:
Try uninstalling your version 1.0-p8 of the library and instead try using the tip of the master branch:
https://github.com/sumotoy/TFT_ILI9163C/archive/master.zip
I believe that is considered version 0.9. It's quite outdated but that may be a good thing. You will need to install the Adafruit_GFX library and there may be some changes necessary in your code. See the included examples for details.
No, it doesn't. See the "conditional inclusions" section of:
http://www.cplusplus.com/doc/tutorial/preprocessor/

The example template won't work for me either. :(.

Arduino: 1.8.2 (Windows 8.1), Board: "Arduino/Genuino Uno"

C:\Users\Towy\AppData\Local\Temp\arduino_modified_sketch_313665\bigPicture.ino: In function 'void setup()':

bigPicture:119: error: 'class TFT_ILI9163C' has no member named 'writeScreen24bit'

   tft.writeScreen24bit(image_data_Image);

       ^

exit status 1
'class TFT_ILI9163C' has no member named 'writeScreen24bit'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What a mess. Change bigPicture.ino line 119 from:

   tft.writeScreen24bit(image_data_Image);

to:

   tft.writeScreen24(image_data_Image);

Thank you... !

same problem here is my code i am fairly new
int val=0;
int tempPin = 1;
int buzzer = 12;//the pin of the active buzzer
int potpin=0;
int ledpin=11;
void setup()
{
pinMode(ledpin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
val=analogRead(potpin);
Serial.println(val);
analogWrite(ledpin,val);
delay(1000);
{
Serial.begin(9600);
}
val = analogRead(tempPin);
float mv = ( val/1024.0)5000;
float cel = mv/10;
float farh = (cel
9)/5 + 32;
Serial.print("TEMPRATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);
int buzzer = 12;
{
pinMode(buzzer,OUTPUT);
{
unsigned char i;
while(1)
{
for(i=0;i<80;i++)
{
digitalWrite(buzzer,HIGH);
delay(1);
digitalWrite(buzzer,LOW);
delay(1);
}
for(i=0;i<100;i++)
{
digitalWrite(buzzer,HIGH);
delay(2);
digitalWrite(buzzer,LOW);
delay(2);
}

The problem is you have some unnecessary opening braces but no matching closing braces. If you do a Tools > Auto Format on your sketch the automatic indentation will make the problem clear. If you're using the Arduino Web Editor then there is no Auto Format available and I recommend using the standard IDE instead if possible as that is a very important tool to have.

pert:
When you encounter an error you should always scroll all the way up and deal with the errors from the top to the bottom of the output because often the later errors are caused by the earlier ones.

You're contradicting yourself a little :wink:

Although I agree that top to bottom is the usual approach, a missing } is often one of the exceptions if I recall correctly.

The OP was edited after I said that, originally we only had the end fragment of the output. You're right that the very first error shown in the output would make you incorrectly think the bug was in the sketch. If the compiler would instead display the error "the opening bracket at line n was never closed" message that would work with the top to bottom workflow. In the case of OP's problem the errors following the first do happen to lead you to look in the library for bugs so a fuzzy top to bottom workflow is effective there but only by chance.

I am having the same problem
here is the code:
int sensorPin = A0;
int sensorValue = 0;
int piezoPin = 9;

void setup()

{ pinMode(sensorPin, INPUT);
{ pinMode(7, OUTPUT);
{ pinMode(6, OUTPUT);
{ pinMode(piezoPin, OUTPUT);
{ digitalWrite(7, HIGH);
{ digitalWrite(6, LOW);
{ delay(5000);
{ digitalWrite(7, LOW);

{

void loop();
if (sensorValue <= 500);
(digitalWrite(piezoPin, HIGH));
(tone(9, 3047, 400));
(delay(1000));
(noTone(8));
(delay(100));
(digitalWrite(7, HIGH));
{
{ delay(1000);
{ digitalWrite(piezoPin, LOW);
digitalWrite(7, LOW);}
}
and here is the error:
C:\Users\user\Desktop\sketch_jun17b\digital_signal_output\DS3231_alarm\DS3231_alarm.ino: In function 'void setup()':

DS3231_alarm:31: error: expected '}' at end of input

}

^

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

DS3231_alarm:31: error: expected '}' at end of input

exit status 1
expected '}' at end of input

Here, have some of mine }}}}}}}}}}

Have you seen the examples in the IDE?

ghoshmf:
I am having the same problem
here is the code:

Your program has WAY too many open brackets. It also has parentheses around many statements where they aren't necessary. I fixed the brackets and parens below. You are using names for some pins but not for others and you are using the names in some places but not others. You are never reading the sensor, just comparing a variable to a constant. Your 'if' contains only a ';' so it does nothing. Try fixing those problems yourself.

int sensorPin = A0;
int sensorValue = 0;
int piezoPin = 9;


void setup()
{
  pinMode(sensorPin, INPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(piezoPin, OUTPUT);
  digitalWrite(7, HIGH);
  digitalWrite(6, LOW);
  delay(5000);
  digitalWrite(7, LOW);
}


void loop()
{
  if (sensorValue <= 500)
  {
    ;
  }
  digitalWrite(piezoPin, HIGH);
  tone(9, 3047, 400);
  delay(1000);
  noTone(8);
  delay(100);
  digitalWrite(7, HIGH);
  delay(1000);
  digitalWrite(piezoPin, LOW);
  digitalWrite(7, LOW);
}