1
votes

I am new at Arduino and I have two questions... I found nothing on the internet about my problems:

for(int i = 0; i < 3; i++) {
  Serial.println("Test: " + i);
}

The output:

test:
est:
st:

Second problem: I am using LiquidCrystal to show a text on the display. It's a Sparkfun Color LCD Shield.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  Serial.begin(9600);
  /* NOT WORKING 
    lcd.begin(16, 2);
    lcd.print("Hello World!");
  */

}

Thanks for helping me!

1

1 Answers

1
votes

The first problem is due to the fact that "Test: " + i is handled with pointer arithmetic, as opposed to string concatenation which is what you clearly have in mind. Either write Serial.print("Test: "); Serial.println(i);, use proper String objects with a concatenation operator or use sprintf.

The second problem is likely caused by the fact that your lcd uses the library ColorLCDShield.h instead of the LiquidCrystal.h, and thus is handled differently than cheaper and more common displays. I suggest you to lookup the documentation specific for your Sparkfun ColorLCD model at their website, they usually provide several code examples for their components.