Cant get I2C LCD with Arduino Uno R4 to display anything due to not having avr/io.h

Hello
I am using an IC2 LCD 16 x 2 module with a Arduino Uno R4 and have followed this guide here I2C Liquid Crystal Displays | Arduino Project Hub in order to try displaying simple text.
When I run my code this error message appears:

..\Documents\Arduino\libraries\Wire\utility\twi.c:25:10: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
          ^~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1

I am using the LiquidCrystal_I2C library by Frank de Brabander. Can anyone point me in the right direction of a I2C library that is compatible with the uno r4 or any way to change my code to work without an avr processor.

#include <LiquidCrystal_I2C.h>

#include  <Wire.h>

//initialize the liquid crystal library
//the first parameter is  the I2C address
//the second parameter is how many rows are on your screen
//the  third parameter is how many columns are on your screen
LiquidCrystal_I2C lcd(0x27,  16, 2);

void setup() {
  
  //initialize lcd screen
  lcd.init();
  // turn on the backlight
  lcd.backlight();
}
void loop() {
  //wait  for a second
  delay(1000)
  // tell the screen to write on the top row
  lcd.setCursor(0,0);
  // tell the screen to write “hello, from” on the top  row
  lcd.print(“Hello, From”);
  // tell the screen to write on the bottom  row
  lcd.setCursor(0,1);
  // tell the screen to write “Arduino_uno_guy”  on the bottom row
  // you can change whats in the quotes to be what you want  it to be!
  lcd.print(“Arduino_uno_guy”);
  
}

Apologies if anything I have said is stupid as I am quite new to coding.
Thank you for your help.

I know this doesn’t answer your question but you have the rows and columns wrong either in the comments or in the code.

Just a SWAG, but, based on the directory shown, it would appear that you have manually installed another Wire library.

The Wire library, like the SPI library and others, is specific to a particular core, and is automatically installed along with each core. There is no need to install any other Wire libraries; and, as you've discovered, doing so can prevent your code from compiling.

Deleting the version of the Wire library you installed will likely get things working again.

3 Likes

Thank you so much for your response, It has sorted my issue.

1 Like

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