Hello World_i2c umschreiben für mein Display klappt irgendwie nicht...

Moin,
ich habe folgenden Code den ich für mein I2C Display 20x4 zeichen umschreiben möchte:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define BACKLIGHT_PIN 13

LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address

//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }

};

void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

// Switch on the backlight
pinMode ( BACKLIGHT_PIN, OUTPUT );
digitalWrite ( BACKLIGHT_PIN, HIGH );

lcd.begin(16,2); // initialize the lcd

for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap );

  • }*
  • lcd.home (); // go home*
  • lcd.print("Hello, ARDUINO "); *
  • lcd.setCursor ( 0, 1 ); // go to the next line*
  • lcd.print (" FORUM - fm ");*
  • delay ( 1000 );*
    }
    void loop()
    {
  • lcd.home ();*
  • // Do a little animation by writing to the same location*
  • for ( int i = 0; i < 2; i++ )*
  • {*
  • for ( int j = 0; j < 16; j++ )*
  • {*
  • lcd.print (char(random(7)));*
  • }*
  • lcd.setCursor ( 0, 1 );*
  • }*
  • delay (200);*
    }
    Jetzt habe ich angefangen und überprüfe das natürlich andauernd damit ich keine Schwierigkeiten beim Kompilieren bekomme:
    #include <Wire.h>
    #inlcude <LCD.h>
    #include <LiquidCrystal_I2C.h>
    #define I2C_ADDR 0x3F // Define I2C Address
    #define BACKLIGHT_PIN 3
    #define En_pin 2
    #define Rw_pin 1
    #define Rs_pin 0
    #define D4_pin 4
    #define D5_pin 5
    #define D6_pin 6
    #define D7_pin 7
    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
    // Creat a set of new characters
    const uint8_t charBitmap[][8] = {
  • { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },*
  • { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },*
  • { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },*
  • { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },*
  • { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },*
  • { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },*
  • { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },*
  • { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }*

};
void setup()
{

  • lcd.begin (20,4,LCD_5x8DOTS);*
  • lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);*
    }
    allerdings bekomme ich ab genau den Punkt folgende Fehlermeldung:
    HelloWorld_i2c.pde:2:2: error: invalid preprocessing directive #inlcude
    kann mich mal einer aufklären was das IDE da von mir will???

Wieso willst Du denn LCD.h UND LiquidCrystal_I2C.h inkludieren? Und wo nimmst du LCD.h überhaupt her?
Der Parameter "LCD_5x8DOTS" sieht auch irgendwiekomisch aus.
Aus dem "POSITIVE" würde ich mal ein "HIGH" machen.

Geilduino:
kann mich mal einer aufklären was das IDE da von mir will???

Kannst Du uns mal aufklären, welche Version der Arduino-IDE und welche Version der LiquidCrystal-Library (wo heruntergeladen) Du verwendest?

Zusatzfrage:
Hast Du schon andere Libraries erfolgreich installiert oder ist das jetzt die erste Library, die Du nachinstalliert hast?

Warum ich die LCD.h inkludiere? hab cih in meinem Testscript für mein Sainsmart_I2C_LCD auch gemacht ohne lief es nicht. ich meine ich kann es ja mal testweise rausnehmen…

das ist das testscript für mein LCD inkl Sensorshield :
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x3F // Define I2C Address
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
lcd.begin (20,4,LCD_5x8DOTS);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); // init the backlight
}

void loop()
{
demoDisplay();

lcd.setBacklight(LOW); // Backlight off
lcd.home (); // go home
lcd.print("ABCDEFGHIJKLMNOPQRST");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("UVWXYZ 0123456789 ");
lcd.setCursor ( 0, 2 ); // go to the next line
lcd.print("abcdefghijklmnopqrst");
lcd.setCursor ( 0, 3 ); // go to the next line
lcd.print("uvwxyz <>!?@#$%&*() ");
lcd.setBacklight(HIGH); // Backlight on
delay(3000);

for (int i = 0; i < 20; i++) {
delay(300);
lcd.scrollDisplayLeft();
}
delay(3000);

for (int i = 0; i < 20; i++) {
delay(300);
lcd.scrollDisplayRight();
}
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.autoscroll(); // This will 'right justify' text from the cursor
lcd.print("autoscroll");
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.noAutoscroll(); // This will 'left justify' text from the cursor
lcd.print("noAutoscroll");
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
// This is for text that flows Right to Left
lcd.rightToLeft();
lcd.print("rightToLeft");
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.leftToRight(); // This is for text that flows Left to Right
lcd.print("leftToRight");
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.print("blink");
lcd.blink(); // Turns on the blinking cursor
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.print("noBlink");
lcd.noBlink(); // Turns off the blinking cursor
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.print("cursor");
lcd.cursor(); // Turns the underline cursor on/off
delay(3000);

lcd.clear(); // clear display, set cursor position to zero
lcd.print("noCursor");
lcd.noCursor(); // Turns the underline cursor on/off
delay(3000);

}

void demoDisplay()
{
lcd.clear(); // clear display, set cursor position to zero
lcd.setBacklight(HIGH); // Backlight on
lcd.setCursor (0,0);
lcd.print("Good afternoon,");
lcd.setCursor (0,1); // go col 0 of line 1
lcd.print("gentlemen.");
delay(1000);
lcd.setCursor (0,2); // go col 0 of line 2
lcd.print("I am a HAL 9000 ");
lcd.setCursor (0,3); // go col 0 of line 3
lcd.print("computer.");
delay(4000);
wipeLines();

lcd.setCursor (0,0);
lcd.print("I became operational");
lcd.setCursor (0,1);
lcd.print("at the H.A.L. plant ");
lcd.setCursor (0,2);
lcd.print("in Urbana, Illinois ");
lcd.setCursor (0,3);
lcd.print("on January 12 1992. ");
delay(4000);
wipeLines();

lcd.setCursor (0,0);
lcd.print("If you'd like to ");
lcd.setCursor (0,1);
lcd.print("hear it I can sing ");
lcd.setCursor (0,2);
lcd.print("it for you. ");
lcd.setCursor (0,3);
lcd.blink(); // Turns on the blinking cursor
delay(4000);
wipeLines();
lcd.noBlink(); // Turns off the blinking cursor
}

void wipeLines() {
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 20; x++) {
lcd.setCursor (x,y);
lcd.print(" ");
delay(5);
}
}
}

Ähem IDE hab ich 1.0.2 und die LiquidCrystal von https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Nein ist meine erste Library die ich Nachgerüstet hab weil ich mit der Lib die im IDE integriert war nicht klarkomme bzw. diese ein wenig veraltet ist glaube ich (zumindest bekomme ich mein LCD damit definitiv nicht zum laufen)

allerdings bekomme ich ab genau den Punkt folgende Fehlermeldung:
HelloWorld_i2c.pde:2:2: error: invalid preprocessing directive #inlcude

kann mich mal einer aufklären was das IDE da von mir will???

Genau das was sie Dir auch sagt :slight_smile:
Nämlich das es keine Direktive namens "INLCUDE" gibt. Weil es "INCLUDE" heissen muss. Genauer natürlich "#include" statt "#inlcude"

Spannend finde ich, das sich erstmal keiner hier um die eigentliche Fehlermeldung gekümmert hat, sondern erstmal Frage zur Lib und den verwendeten Files kommen :slight_smile:

Mario.

Lol ich schmeiss mich weg… da muss man erst mal drauf kommen. ich probier's mal. Mal was anderes, bin ja Anfänger was Mikrocontroller und Arduino anbelangt. Gibt's jemanden bei euch der mir auch per Skype helfen könnte wenn ich fragen habe?

Habs hinbekommen irgendwie ist mein LCD schon ein wenig eigenartig XD
Hier das Script:

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x3F // Define I2C Address
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }

};

void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

lcd.begin (20,4,LCD_5x8DOTS);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap );

  • }*
  • lcd.setBacklight(HIGH);*
  • lcd.home (); // go home*
  • lcd.print("Hello, ARDUINO "); *
  • lcd.setCursor ( 0, 1 ); // go to the next line*
  • lcd.print (" FORUM - fm ");*
  • delay ( 1000 );*
    }
    void loop()
    {
  • lcd.home ();*
  • // Do a little animation by writing to the same location*
  • for ( int i = 0; i < 2; i++ )*
  • {*
  • for ( int j = 0; j < 16; j++ )*
  • {*
  • lcd.print (char(random(7)));*
  • }*
  • lcd.setCursor ( 0, 1 );*
  • }*
  • delay (200);*
    }

Na Supi funktioniert ja soweit allerdings hab ich den Schriftzug "arduino.cc" den ich gern in der 3ten Zeile zentrieren würde, und in den ersten beiden Zeilen (hab ich ja schon) eine kleine animation, diese soll auch in die 4te Zeile sowie mit jeweils 1 Char abstand zu dem Schriftzug links und rechts auch diese animation. Wie genau bekommt man sowas hin?

Wie genau bekommt man sowas hin?

Indem man rauskriegt, was der gefundene sketch genau macht und es dann vorsichtig ändert
(oder umgekehrt: durch Ändern kriegt man evtl. raus wie es funktioniert)

michael_x:

Wie genau bekommt man sowas hin?

Indem man rauskriegt, was der gefundene sketch genau macht und es dann vorsichtig ändert
(oder umgekehrt: durch Ändern kriegt man evtl. raus wie es funktioniert)

Wie es funktioniert hab ich ja raus (bin aber noch lernfähig), und was es genau macht bekomm ich ja auch noch auf die reihe. Allerdings bin ich immer ein wenig verwirrt wenn ich Fehlermeldungen erhalte (hab ich jetzt gerade auch, nur das ich zwei Shields gleichzeitig betreiben möchte[ ist aber ein anderes Thema])

Geilduino:
Allerdings bin ich immer ein wenig verwirrt wenn ich Fehlermeldungen erhalte.

Versuch sie dann mal zu übersetzen:
error: invalid preprocessing directive #inlcude ( = Fehler: fehlerhafte Präprozessor direktive #inlcude)
Die Zeilen stehen auch in der Fehlermeldung. Schau die einfach dann auch mal die Zeilen an und
such den Syntaxfehler.

Addi

was es genau macht bekomm ich ja auch noch auf die reihe

Da wollen wir dir doch den Spass nicht verderben, dass du selbst die "Animation" so änderst wie du möchtest.

Das mit dem "invalid preprocessing directive #inlcude" ist natürlich schwer selbst zu finden. Super Mario :wink:
Aber generell hilft es schon, sich die Fehlermeldungen so genau wie möglich anzuschauen.

Und zur Sicherheit mal einen "ziemlich guten" Zwischenstand aufheben. Wenn man was total vermurkst hat ...