Hilfe bei Code...

Hallo Leute,

ich arbeite gerade mit der Liquid Crystal Library und habe folgendes Problem:

Ich kann ja mit lcd.print("HALLO"); einen Text auf dem Display erscheinen lassen. Nun würde ich gerne den Text "Hallo" & den Wert der Variablen "Value" anzeigen lassen, habe aber keine Ahnung wie das gehen soll. Bei Visual Basic geht es so: Text1.Text="Hallo:" & Value

Wie bekomme ich das hin?

danke für eure Hilfe

LG silentforce

Ganz einfach, neue Zeile dazufügen. Also:

lcd.print("HALLO:");
lcd.print(Value);

Nabend, entweder so oder mal wieder den guten alten
Kumpel sprintf benutzen
char Buffer[10];
int Value=13;
sprintf(Buffer,"Hallo %i",Value);
LCD.Print(Buffer);

gruß jkw

sprintf(Buffer,"Hallo %i",Value);

In welcher Bibliothek ist der Befehl sprintf eigentlich enthalten ?

In einer die automatisch includiert wird. Mußte io.h sein, wenn ich mir richtig erinnere.
Grüße Uwe

Hier findest Du weitere Möglichkeiten.

[...]
// This doesn't work in Arduino. Too bad.
lcd.print("The button was pressed " + counter + " times");

Meanwhile, experienced programmers chafe at having to synthesize streams with clumsy blocks of repetitive code like this:

lcd.print("GPS #");
lcd.print(gpsno);
lcd.print(" date: ");
lcd.print(day);
lcd.print("-");
lcd.print(month);
lcd.print("-");
lcd.println(year); // ugh!!

The Streaming library gives you the option of compressing those into “insertion style” code that, if not exactly the same, is reminiscent of the concatenation above:

lcd << "GPS #" << gpsno << " date: " <<
day << "-" << month << "-" << year << endl;
[...]

Wurde der obere Teil nicht mit Version ~20 implementiert ?
Ungetestet.

@Uwefed

Hallo Uwe,

hast recht die Bibliothek wird offensichtlich automatisch eingebunden !

@jkw
Nein. Es gibt beim compilieren einen Fehler.

aber so gehts:

void setup(){
};

void loop(){
  String stringOne;
  stringOne = String("A long integer: ");

  // adding a constant long integer to a string:
  stringOne += 123456789;
  Serial.println(stringOne);   // prints "A long integer: 123456789"
}