Pages: [1]   Go Down
Author Topic: Adafruit LCD shield - keeps displaying wrong text  (Read 71 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

So I just got in my new Adafruit RGB LCD shield.. I've been playing around with the HelloWorld example that comes with their library. I'm trying to get it to display a string and for some reason it keeps displaying either "Hello World"!  smiley-mad I tried sending the output to the Serial Monitor to troubleshoot, and it's the same story. Now, if I change the Serial output to the individual pieces of the String I'm trying to display it works. As soon as I try to display the whole string I get "Hello, World". I'm sure that the culprit for this is blatantly obvious, but I can't figure it out.. Please someone enlighten me!
Code:
/*********************

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
int hours = 1;
int minutes =1;
String var="";

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 :)
  int time = millis();
  lcd.print("Hello, world!");
  time = millis() - time;
  Serial.print("Took "); Serial.print(time); Serial.println(" ms");
  lcd.setBacklight(WHITE);
  var = String(hours + ":" + minutes);
}

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(var);
      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);
    }
  }
}
« Last Edit: September 20, 2014, 07:59:13 pm by guitarmaniak8 » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 4401
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Go back and 'modify' your original post.  Highlight the portion of that post that is code and press the 'code' button, the one that looks like an octothorpe ( # ).

Quote
Please someone enlighten me!
You are going to have to enlighten us first.

Quote
I've been playing around with the HelloWorld example that comes with their library.
Does this mean that the example worked as provided and you are now modifying it?

Quote
I'm trying to get it to display a string and for some reason it keeps displaying either "Hello World"!
The only string in your sketch is "Hello, world!" so what did you expect it to display? 
You use the word 'either' but you haven't told us what the other something or other is.


Quote
Now, if I change the Serial output to the individual pieces of the String I'm trying to display it works.
It's crackers to slip a rozzer the dropsy in snide.

Don
Logged

Pages: [1]   Go Up
Jump to: