An invalid header file

To cut it short, a code I downloaded from the internet doesn't seem to work... Yes I've just copy and pasted it and yes the pre-requisite libraries seem to check out I've read the other related topics on this however nothing seems to work..


Any advice/solution on the topic would be much appreciated!

change begin() to begin (16,2)

2 Likes

There are multiple libraries that have the LiquidCrystal_I2C.h header file, you likely have the wrong one.

Look at the example sketches for the library you have, and write the code to fit.

3 Likes

The library that takes that call to begin() will likely not have the constructor that contains the same 16 & 2.

1 Like

Trust me, it will work!

2 Likes

woah ok changing it to (16, 2) does work! slight issue though.. I think david is right because nothing seems to.. show

any ideas on how I could make it work?

the thing that should pop up on the lcd should look like this

it'll move up and down and what have you. For more references here's the video. https://www.youtube.com/watch?v=IxyVwyyooWU

how doI exactly fix that? Tinkercad only jhas like... 2 and the current lcd i am using is a I2C.

Your image shows the I2C address of the display as 0x27, but the code has the line:

LiquidCrystal_I2C lcd(0x3F, 16, 2);//

which uses the I2C address of 0x3F.

2 Likes

Nothing seems to work.. I've been at it for an hour but I can't seem to get anything to show.. I re arranged the addresses but something just doesn't work...

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);//
int i=0;
int j=0;
int randomnum;
int k=0;
byte customChar1[] = {
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F
};

byte customChar2[] = {
  0x00,
  0x00,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F,
  0x1F
};
byte customChar3[] = {
  0x00,
  0x00,
  0x00,
  0x00,
  0x1F,
  0x1F,
  0x1F,
  0x1F
};
byte customChar4[] = {
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x1F,
  0x1F
};
byte customChar5[] = {
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x00,
  0x00
};
void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.createChar(4, customChar1);
  lcd.createChar(3, customChar2);
  lcd.createChar(2, customChar3);
  lcd.createChar(1, customChar4);
  lcd.createChar(0, customChar5);
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("Welcome");
  lcd.setCursor(0,1);
  lcd.print("TeachMeSomething");
  delay(2000);
 lcd.clear();
}

void loop() { 
  randomnum=random(6,9);
  Serial.print ("random numer = ");
  Serial.println (randomnum);
  
for (i=randomnum ; i>0; i=i-3)
 {
 int z=i;
  Serial.print ("i value = ");
  Serial.println (i);
  Serial.print ("j= ");
  Serial.println (j);
  Serial.print ("k= ");
  Serial.println (k);
    test();
    lcd.setCursor(7,0);
    lcd.write(j);
    lcd.setCursor(7,1);
    lcd.write(k);
    i--;
    test();
    lcd.setCursor(8,0);
    lcd.write(j);
    lcd.setCursor(8,1);
    lcd.write(k);
   lcd.setCursor(6,0);
    lcd.write(j);
    lcd.setCursor(6,1);
    lcd.write(k);
     i--;
    test();
    lcd.setCursor(9,0);
    lcd.write(j);
    lcd.setCursor(9,1);
    lcd.write(k);
   lcd.setCursor(5,0);
    lcd.write(j);
    lcd.setCursor(5,1);
    lcd.write(k);

      i--;
    test();
    lcd.setCursor(10,0);
    lcd.write(j);
    lcd.setCursor(10,1);
    lcd.write(k);
    lcd.setCursor(4,0);
    lcd.write(j);
    lcd.setCursor(4,1);
    lcd.write(k);

     i--;
    test();
    lcd.setCursor(11,0);
    lcd.write(j);
    lcd.setCursor(11,1);
    lcd.write(k);
   lcd.setCursor(3,0);
    lcd.write(j);
    lcd.setCursor(3,1);
    lcd.write(k);

     i--;
    test();
    lcd.setCursor(12,0);
    lcd.write(j);
    lcd.setCursor(12,1);
    lcd.write(k);
   lcd.setCursor(2,0);
    lcd.write(j);
    lcd.setCursor(2,1);
    lcd.write(k);

     i--;
    test();
    lcd.setCursor(13,0);
    lcd.write(j);
    lcd.setCursor(13,1);
    lcd.write(k);
   lcd.setCursor(1,0);
    lcd.write(j);
    lcd.setCursor(1,1);
    lcd.write(k);

     i--;
    test();
    lcd.setCursor(14,0);
    lcd.write(j);
    lcd.setCursor(14,1);
    lcd.write(k);
   lcd.setCursor(0,0);
    lcd.write(j);
    lcd.setCursor(0,1);
    lcd.write(k);
    
    delay(50);
    lcd.clear();
   
 i=z;
 }
 }

void test()
{

  if (i ==8)
   {
    j= 4;
    k=4;
  }
   if (i ==7)
  {
    j=3;
    k=4;
  }
   if (i ==6)
  {
    j=2;
    k=4;
  }
     if (i ==5)
  {
    j=1;
    k=4;
  }
     if (i ==4)
  {
    j=0;
    k=4;
  }
     if (i ==3)
  {
    j=0;
    k=3;
  }
     if (i ==2)
  {
    j=0;
    k=2;
  }
     if (i ==1)
  {
    j=0;
    k=1;
  }
     if (i ==0)
  {
    j=0;
    k=0;
  }
  }

Evertyhing seems to check out... I feel like I'm missing something

image
have you tried doing this?

1 Like

Run the I2C scanner sketch to find the address. Then we can go from there.

1 Like

hello hello! sorry for the late replies schools been real busy the past few days... anywho! yes I have set the address to that! Nothing seems to work still...

Thanks to david_2018 and bobcousins we've now figured out how to get that invalid header file problem up and out. Now its how do I get it to display? Sorry if I seem to be a bit clueless. I am incredibly inexperienced with these types of coding... I only know the most basic types of coding like led's, motors, and so on. Any help would be much obliged!

You need to make sure you have the same I2C address. I don't know which is the "correct" address; I would change the code to match the simulator.

1 Like


it didn't work:(

See post #12

You need to call lcd.init() after lcd.begin()

  lcd.begin(16, 2);
  lcd.init();

so uhm... how exactly do i do that

I'm not familiar with which LiquidCrystal_I2C library is used for Tinkercad, does anyone know if lcd.backlight() needs to be called to turn the display backlight on?