Lcd.print text+Variablen

Hallo,
Ich würde gerne in einer zeile ein Text plus eine Variable ausgeben

Meine idee war
Lcd.print("text",x); wobei x eine int variable wäre

Aber leider geht dasso nicht , was mache ich falsch?

Gruß Jörg

Please post in English in the English forum.

There is a German forum section.

I would like to output a text plus a variable in one line My idea was Lcd.print("text",x); where x would be an int variable But unfortunately it doesn't work that way, what am I doing wrong? Greetings Jörg

Use 2 prints:

lcd.print("text ");
lcd.print(x);

Use sprintf():

char buffer[10];
sprintf(buffer, "text %d", x);
print(buffer);

That's OK, he writes in German. ;)

#include <Streaming.h> // die Lib findest du selber ;-)

// lcd definition

void setup() 
{

  // lcd init

  int x = 42;

  lcd << "test" << x ;
}

void loop() 
{

}

kannste das auch so posten das es auf Anhieb compiliert?

Nein!Edit: Ja! (damit du nicht doof sterben musst)
Es gibt gefühlte 12999 lcd Libs!
KA, welche du oder der TO benutzt.

Funktionieren tut es mit allen mir bekannten.
Exakt so wie beschrieben.

Oder hast du Probleme die Streaming Lib im Library Manager zu finden?
Dann erkläre ich dir gerne, wie der Manager funktioniert. (gegen Rechnung)

Hier ein Beispiel:
Kompiliert und funktioniert.

#include <Streaming.h> // die Lib findest du selber ;-)
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>


// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() 
{

  // initialize the LCD
  lcd.begin();

  // Turn on the blacklight and print a message.
  lcd.backlight();


  int x = 42;

  lcd << "test" << x ;
}

void loop() 
{

}

@combie

du hast dich weiterentwickelt vom Dokuvorleseverweigerer zum compilierverweigerer

Und du vom **** zum *** *** ***!

1 Like

Dafür braucht es nur zwei kleine Ersetzungen und nicht mal ein Display.

- // lcd definition
+ #define lcd Serial

-   // lcd init
+   lcd.begin(115200);

Ausgabe:

test42

Ohh - combie war schneller.
Entschuldige bitte, dass ich #define verwende.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.