Adafruit_RGBLCDShield Error code help

I just got the Adafruit_RGBLCDShield for my arduino uno r3, the example code that came with it works great, but once I tried my own code it came up with error codes that I don’t understand and/or don’t know how to fix. Please help.

This is the program code: It does not compile

#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define GREEN 0x2
void setup() {
lcd.begin (16, 2);
lcd.setBacklight(GREEN);
}
uint8_t i=0;
void loop() {
uint8_t buttons = lcd.readButtons();
if (buttons & BUTTON_UP) {
lcd.setCursor(0,0);
lcd.print(“HI”);
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“How are you?”);
}
}
This is the error code:
Arduino: 1.6.3 (Mac OS X), Board: “Arduino Uno”

In file included from sketch_jul14c123456.ino:1:0:
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:20:14: error: ‘uint8_t’ has not been declared
void begin(uint8_t addr);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:23:16: error: ‘uint8_t’ has not been declared
void pinMode(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:23:27: error: ‘uint8_t’ has not been declared
void pinMode(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:24:21: error: ‘uint8_t’ has not been declared
void digitalWrite(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:24:32: error: ‘uint8_t’ has not been declared
void digitalWrite(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:25:15: error: ‘uint8_t’ has not been declared
void pullUp(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:25:26: error: ‘uint8_t’ has not been declared
void pullUp(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:26:3: error: ‘uint8_t’ does not name a type
uint8_t digitalRead(uint8_t p);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:28:20: error: ‘uint16_t’ has not been declared
void writeGPIOAB(uint16_t);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:29:3: error: ‘uint16_t’ does not name a type
uint16_t readGPIOAB();
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:32:3: error: ‘uint8_t’ does not name a type
uint8_t i2caddr;
^
Error compiling.

This is the example that came with the library:

/*********************

Example code for the Adafruit RGB Character LCD Shield and Library

This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.

**********************/

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can’t use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

void setup() {
// Debugging output
Serial.begin(9600);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);

// Print a message to the LCD. We track how long it takes since
// this library has been optimized a bit and we’re proud of it :slight_smile:
int time = millis();
lcd.print(“Hello, world!”);
time = millis() - time;
Serial.print(“Took “); Serial.print(time); Serial.println(” ms”);
lcd.setBacklight(WHITE);
}

uint8_t i=0;
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);

uint8_t buttons = lcd.readButtons();

if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
lcd.print("UP ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_DOWN) {
lcd.print("DOWN ");
lcd.setBacklight(YELLOW);
}
if (buttons & BUTTON_LEFT) {
lcd.print("LEFT ");
lcd.setBacklight(GREEN);
}
if (buttons & BUTTON_RIGHT) {
lcd.print("RIGHT ");
lcd.setBacklight(TEAL);
}
if (buttons & BUTTON_SELECT) {
lcd.print("SELECT ");
lcd.setBacklight(VIOLET);
}
}
}

I’m using the arduino IDE version 1.6.3
Arduino uno R3
Macbook mid2010 running Yosemite
8 GB RAM

Shield/Library: Overview | RGB LCD Shield | Adafruit Learning System

Please help if you can. :slight_smile:

It does not make sense that creating your own sketch causes errors in the library code. But, the last error is easy to explain.

sketch_jul14c123456.ino:11:6: error: 'buttons' was not declared in this scope

Where DID you define buttons? Nowhere is not a good answer.

Do you get SIMILAR compiler errors when you comment out ALL code in loop()? Missing declaration of buttons SHOULD not make compiler go crazy like this.

Can you post the sample code you got working?

This the example that came with it:

/*********************

Example code for the Adafruit RGB Character LCD Shield and Library

This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.

**********************/

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can’t use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

void setup() {
// Debugging output
Serial.begin(9600);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);

// Print a message to the LCD. We track how long it takes since
// this library has been optimized a bit and we’re proud of it :slight_smile:
int time = millis();
lcd.print(“Hello, world!”);
time = millis() - time;
Serial.print(“Took “); Serial.print(time); Serial.println(” ms”);
lcd.setBacklight(WHITE);
}

uint8_t i=0;
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);

uint8_t buttons = lcd.readButtons();

if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
lcd.print("UP ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_DOWN) {
lcd.print("DOWN ");
lcd.setBacklight(YELLOW);
}
if (buttons & BUTTON_LEFT) {
lcd.print("LEFT ");
lcd.setBacklight(GREEN);
}
if (buttons & BUTTON_RIGHT) {
lcd.print("RIGHT ");
lcd.setBacklight(TEAL);
}
if (buttons & BUTTON_SELECT) {
lcd.print("SELECT ");
lcd.setBacklight(VIOLET);
}
}
}

I tries adding 2 lines of code that I forgot, but now it comes up with a different error.

Arduino: 1.6.3 (Mac OS X), Board: “Arduino Uno”

In file included from sketch_jul14c123456.ino:1:0:
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:20:14: error: ‘uint8_t’ has not been declared
void begin(uint8_t addr);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:23:16: error: ‘uint8_t’ has not been declared
void pinMode(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:23:27: error: ‘uint8_t’ has not been declared
void pinMode(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:24:21: error: ‘uint8_t’ has not been declared
void digitalWrite(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:24:32: error: ‘uint8_t’ has not been declared
void digitalWrite(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:25:15: error: ‘uint8_t’ has not been declared
void pullUp(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:25:26: error: ‘uint8_t’ has not been declared
void pullUp(uint8_t p, uint8_t d);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:26:3: error: ‘uint8_t’ does not name a type
uint8_t digitalRead(uint8_t p);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:28:20: error: ‘uint16_t’ has not been declared
void writeGPIOAB(uint16_t);
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:29:3: error: ‘uint16_t’ does not name a type
uint16_t readGPIOAB();
^
/Users/username/Documents/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library-master/Adafruit_MCP23017.h:32:3: error: ‘uint8_t’ does not name a type
uint8_t i2caddr;
^
Error compiling.

This is the code I used:

#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define GREEN 0x2
void setup() {
lcd.begin (16, 2);
lcd.setBacklight(GREEN);
}
uint8_t i=0;
void loop() {
uint8_t buttons = lcd.readButtons();
if (buttons & BUTTON_UP) {
lcd.setCursor(0,0);
lcd.print(“HI”);
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“How are you?”);
}
}

Please help if you can.

Can you compile this?
It looks as you are missing a library, but it makes little sense since you claim the code that came "with it " works.

#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Wire.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define GREEN 0x2
void setup() {
 lcd.begin (16, 2);
 lcd.setBacklight(GREEN);
}
//uint8_t i=0;
void loop() {
//uint8_t buttons = lcd.readButtons();
// if (buttons & BUTTON_UP) {
//  lcd.setCursor(0,0);
//  lcd.print("HI");
//  delay(5000);
//  lcd.clear();
//  lcd.setCursor(0,0);
//  lcd.print("How are you?");
}
}

That code didn’t come with it. I used the example to help me make it(used the same code to control everything) but it still came up with more errors

Arduino_Lover1010: That code didn't come with it. I used the example to help me make it(used the same code to control everything) but it still came up with more errors

Does the code in my previous post compile?

Yes or no?

This the example that came with it:

which contains:

lcd.print(millis()/1000);

 uint8_t buttons = lcd.readButtons();

 if (buttons) {

Notice that buttons IS declared.

This is the code I used:

That is NOT the code posted in the original post.

You also claimed, initially, that the example worked. If the example can not even compile, there isn't a snowball's chance in hell that it worked.

So, exactly where are you blowing smoke?

NO that code above from vaclav does not compile

Arduino_Lover1010:
NO that code above from vaclav does not compile

Now we are getting somewhere.

Have you installed the Ada TFT libraries?

If not , and all the indicators say you have not, why don’t you use Arduino TFT examples and run those?
Use TFT library included in IDE, it may work with your TFT LCD controller, but it is no guarantee!

I would suggest download and run TFTDisplayText. At least it will compile!

That example won't compile because there's an extraneous brace at the end. The end brace which matches the "if" statement needs to be commented out too.

Pete

el_supremo:
That example won’t compile because there’s an extraneous brace at the end. The end brace which matches the “if” statement needs to be commented out too.

Pete

el_supremo:
That example won’t compile because there’s an extraneous brace at the end. The end brace which matches the “if” statement needs to be commented out too.

Pete

Good catch , but I guess I did not say to OP

PLEASE post the compiler output.

Wrong if and missing library are TWO entirely different error outputs IMHO.

Arduino_Lover1010: NO that code above from vaclav does not compile

PLEASE post the compiler output.

I added the build in TFT library but it gave more error codes. Posted the new code and the new error code at the top.

The build in TFT does not control my LCD display, it uploads, but nothing happens.

I added the build in TFT library but it gave more error codes. Posted the new code and the new error code at the top.

Do NOT do that. The code that was posted initially had other problems. All the replies between there and hear now look stupid. I, for one, won't help any more when you do that.