Error help on Arduino Uno

Not sure if i've posted in the correct area - apologies if not

Im a total newbie to this. Ive tried to paste someone elses code into IDE tonight and getting this error. Obviously I've done something wrong?

Can anyone advise?

Thanks

C:\Users\ameth\AppData\Local\Temp.arduinoIDE-unsaved2024011-3372-nh435j.eaqd\sketch_jan11a\sketch_jan11a.ino:2:10: fatal error: LiquidCrystal_I2C.h: No such file or directory
#include <LiquidCrystal_I2C.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: LiquidCrystal_I2C.h: No such file or directory

Although you have not posted your sketch properly (that was hint to use code tags), the error message seems clear. The compiler cannot find the LiquidCrystal_I2C library

Is it installed on your PC and, of so, where is it located ?

1 Like

You must to install LiquidCrystal_I2C library.
See the tutorial

1 Like

Before going further, please read the forum guidelines
I shouldn't use a screenshots instead of the code.

1 Like

I wasn't aware I needed to do this. Thanks UKHeliBob and b707. I will follow the guide posted by b707

Apologies but didn't realise. I will follow the guide on installation above

I have now added the file needed. I now get the below error:
C:\Users\ameth\AppData\Local\Temp.arduinoIDE-unsaved2024012-3372-1gqx5y2.dimm\sketch_jan12a\sketch_jan12a.ino:10:53: error: 'POSITIVE' was not declared in this scope
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
^~~~~~~~
C:\Users\ameth\AppData\Local\Temp.arduinoIDE-unsaved2024012-3372-1gqx5y2.dimm\sketch_jan12a\sketch_jan12a.ino:94:1: error: expected unqualified-id before ']' token
]
^

exit status 1

Compilation error: 'POSITIVE' was not declared in this scope

Can you help?

Please post your full sketch, using code tags when you do

1 Like

sorry to sound totally thick but what are code tags? thanks

[#include](https://www.youtube.com/hashtag/include)

#include <LiquidCrystal_I2C.h>

int credit = 0;

int creditdisplay = 0;

const int hopperInt = 10;

byte hopperDebounceDelay = 100;

long lastHopperDebounceTime = 0;

int previousMillis;

int interval = 500;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup()

{

digitalWrite (8,HIGH);

Serial.begin(9600);

pinMode(10, INPUT_PULLUP);

pinMode(8, OUTPUT);

pinMode(9, INPUT_PULLUP);

lcd.begin(20, 4);

lcd.setCursor(1,0);

lcd.print("CHANGE MACHINE v1.0");

lcd.setCursor(2,2);

delay(1000);

lcd.print("DINKY COIN PUSHERS");

delay(3000);

lcd.clear();

lcd.setCursor(3,4);

lcd.print("INITIALISING...");

delay(3000);

lcd.clear();

lcd.setCursor(3,1);

lcd.print("INSERT COIN(S)");

lcd.setCursor(3,2);

lcd.print("FOR 2p CHANGE");

}

void loop()

{

//lcd.print("1");

int CoinVal = digitalRead(9);

int HopperSense = digitalRead(7);

//Serial.println(SensorVal);

if (CoinVal == HIGH)

{

}

else

{

credit = credit + 1;

creditdisplay = creditdisplay + 1;

Serial.println(credit);

Serial.print(creditdisplay);

Serial.println(" Credits");

lcd.clear();

lcd.setCursor(1,1);

lcd.print("Coins to Pay:");

lcd.setCursor(14,1);

lcd.print(creditdisplay);

delay(20);

}

if(credit > 0)

{

digitalWrite(8, LOW);

if (digitalRead(hopperInt) == LOW && ((millis() - lastHopperDebounceTime) > hopperDebounceDelay))

\

lastHopperDebounceTime = millis();

Serial.println("CoinPaid");

credit = credit - 1;

lcd.setCursor(1,2);

lcd.print("Coins Paid");

lcd.setCursor(14,2);

lcd.print(creditdisplay - credit);

if(credit == 0)

{

creditdisplay = 0;

digitalWrite(8, HIGH);

delay(2000);

lcd.clear();

lcd.setCursor(3,1);

lcd.print("INSERT COIN(S)");

lcd.setCursor(3,2);

lcd.print("FOR 2p CHANGE");

}

}

}

]

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

Hi @amethystangel

There are two common libraries with a header file named LiquidCrystal_I2C.h. These libraries have different APIs so if you try to compile a sketch that was written for one library while the other library is installed, compilation will fail with an error like the one you reported here.

I think the best solution will be for you to install the library your sketch was written to be used with. I'll provide instructions:

A. Uninstall Incorrect Library

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
  2. Type LiquidCrystal I2C in the "Filter your search..." field.
  3. Scroll down through the list of libraries until you see the "LiquidCrystal I2C by Frank de Brabander" entry.
  4. You will see an "REMOVE" button at the bottom of the entry. Click the button.
    The "Uninstall" dialog will open.
  5. Click the "YES" button in the "Uninstall" dialog.
  6. Wait for the uninstall process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:

    ⓘ Successfully installed library LiquidCrystal I2C: ...

B. Install Correct Library

Unfortunately the correct library is not available for installation via the Arduino Library Manager so a different installation procedure is required than usual:

  1. Click the following link to open the library's GitHub repository homepage in your web browser:
    https://github.com/fmalpartida/New-LiquidCrystal
  2. Click the "Code ▾" button you see on that page.
  3. Select Download ZIP from the menu.
    A download of the ZIP file of the library will start.
  4. Wait for the download to finish.
  5. Select Sketch > Include library > Add .ZIP Library from the Arduino IDE menus.
    The "Select the zip file containing the library you'd like to add" dialog will open.
  6. Select the downloaded file from the dialog.
  7. Click the "Open" button.
  8. Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:

    ⓘ Successfully installed library from New-LiquidCrystal-master.zip archive

Now try compiling your sketch again. Hopefully this time it will compile without any errors.

Many thanks - that error is solved :slight_smile:

I know have the below error:

C:\Users\ameth\AppData\Local\Temp.arduinoIDE-unsaved2024012-3372-1gqx5y2.dimm\sketch_jan12a\sketch_jan12a.ino:94:1: error: expected unqualified-id before ']' token
]
^

exit status 1

Compilation error: expected unqualified-id before ']' token

Please post your full sketch.

I'll provide instructions you can follow to do that:

  1. Do an Auto Format on your code by pressing Ctrl+B.
    This is done to make the code easier for us to read.
  2. Click on the window that contains your sketch code.
  3. Press the Ctrl+A keyboard shortcut.
    This will select all the text.
  4. Press the Ctrl+C keyboard shortcut.
    This will copy the selected text to the clipboard.
  5. In a forum reply here, click on the reply field.
  6. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  7. Press the Ctrl+V keyboard shortcut.
    This will paste the compilation output into the code block.
  8. Move the cursor outside of the code block markup before you add any additional text to your reply.
  9. Repeat the above process if your sketch has multiple tabs.
  10. Click the "Reply" button to post the output.
#include <Wire.h> 
#include <LiquidCrystal_I2C.h> 
int credit = 0; 
int creditdisplay = 0; 
const int hopperInt = 10; 
byte hopperDebounceDelay = 100; 
long lastHopperDebounceTime = 0; 
int previousMillis; 
int interval = 500; 
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 
void setup() 
{ 
 digitalWrite (8,HIGH); 
 Serial.begin(9600); 
 pinMode(10, INPUT_PULLUP); 
 pinMode(8, OUTPUT); 
 pinMode(9, INPUT_PULLUP); 

 lcd.begin(20, 4); 
 lcd.setCursor(1,0); 
 lcd.print("CHANGE MACHINE v1.0"); 
 lcd.setCursor(2,2); 
 delay(1000); 
 lcd.print("DINKY COIN PUSHERS"); 
 delay(3000); 
 lcd.clear(); 
 lcd.setCursor(3,4); 
 lcd.print("INITIALISING..."); 
 delay(3000); 
 lcd.clear(); 
 lcd.setCursor(3,1); 
 lcd.print("INSERT COIN(S)"); 
 lcd.setCursor(3,2); 
 lcd.print("FOR 2p CHANGE"); 
}
void loop() 
{

//lcd.print("1"); 

int CoinVal = digitalRead(9); 
int HopperSense = digitalRead(7); 
//Serial.println(SensorVal); 

if (CoinVal == HIGH)
{

} 
else 
{ 
 credit = credit + 1; 
 creditdisplay = creditdisplay + 1; 

 Serial.println(credit);
 Serial.print(creditdisplay);
 Serial.println(" Credits");
 lcd.clear();
 lcd.setCursor(1,1);
 lcd.print("Coins to Pay:"); 
 lcd.setCursor(14,1);
 lcd.print(creditdisplay); 
 delay(20);

}

 if(credit > 0)
  {
  digitalWrite(8, LOW);
  if (digitalRead(hopperInt) == LOW && ((millis() - lastHopperDebounceTime) > hopperDebounceDelay)) 
  \ 
  lastHopperDebounceTime = millis();
  Serial.println("CoinPaid");
  credit = credit - 1; 
  lcd.setCursor(1,2); 
  lcd.print("Coins Paid"); 
  lcd.setCursor(14,2); 
  lcd.print(creditdisplay - credit); 

  if(credit == 0) 
  { 
    creditdisplay = 0; 


  digitalWrite(8, HIGH); 
  delay(2000); 
  lcd.clear(); 
  lcd.setCursor(3,1); 
  lcd.print("INSERT COIN(S)"); 
  lcd.setCursor(3,2); 
  lcd.print("FOR 2p CHANGE");
  } 
} 
} 
]

Thank you for the explaination - hopefully i have done it correctly above :slight_smile:

Thank you. Now this error code! This is driving me crazy!

C:\Users\ameth\AppData\Local\Temp.arduinoIDE-unsaved2024012-3372-1gqx5y2.dimm\sketch_jan12a\sketch_jan12a.ino:94:1: error: expected declaration before '}' token
}
^

exit status 1

Compilation error: expected declaration before '}' token

Many thanks everyone - i think i've done it!!

Don't think I'll do much coding lol

I've uploaded the sketch to the arduino uno successfully but the lcd isn't showing anything. It lights up and the red led is lit on the back but the screen is totally blank. Is this the right section or do i need to post to another? thanks