LCD I2C program error message

Hey I am trying to learn how to use a LCD display with the arduino but I’m having some trouble. What does this error message mean:

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp: In member function 'virtual void LiquidCrystal::send(uint8_t, uint8_t)':

C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp:137:48: error: cannot convert 'bool' to 'PinStatus' for argument '2' to 'void digitalWrite(pin_size_t, PinStatus)'

    digitalWrite( _rs_pin, ( mode == LCD_DATA ) );

                                                ^

C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp: In member function 'void LiquidCrystal::writeNbits(uint8_t, uint8_t)':

C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp:329:48: warning: invalid conversion from 'int' to 'PinStatus' [-fpermissive]

       digitalWrite(_data_pins[i], (value >> i) & 0x01);

                                   ~~~~~~~~~~~~~^~~~~~

In file included from C:\Users\caxpo\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/ArduinoAPI.h:52:0,

                 from C:\Users\caxpo\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:23,

                 from C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp:48:

C:\Users\caxpo\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/api/Common.h:104:6: note:   initializing argument 2 of 'void digitalWrite(pin_size_t, PinStatus)'

 void digitalWrite(pin_size_t pinNumber, PinStatus status);

      ^~~~~~~~~~~~

Multiple libraries were found for "LiquidCrystal_I2C.h"
 Used: C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib
 Not used: C:\Users\caxpo\Documents\Arduino\libraries\LiquidCrystal_I2C-1.1.2
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.
No files were added to the sketch.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

It means exactly what it says.

 digitalWrite( _rs_pin, ( mode == LCD_DATA ) ? HIGH : LOW);

I don't understand it. What does it mean?

It means that there is no defined conversion from ‘bool’ (the result of a comparison) to “PinStatus” (the type expected by “digitalWrite”'s second argument)

The term in the paranthesis is a special expression of the C language.
( mode == LCD_DATA ) ? HIGH : LOW); means...
if (mode == LCD_DATA)
then pin_state = HIGH;
else pin_state = LOW;

pin_state is then given to the digitalWrite statement.

Okay I think I understand, so what can I do to make it work?

I already showed you.

Koba_Prime:
what can I do to make it work?

Open C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp in a text editor.

Change line 137 from:

digitalWrite( _rs_pin, ( mode == LCD_DATA ) );

to the corrected code @TheMemberFormerlyKnownAsAWOL provided:

digitalWrite( _rs_pin, ( mode == LCD_DATA ) ? HIGH : LOW);

Save the file.

Your sketch should now compile without that error.

The error is caused by the 2nd argument of digitalWrite() being defined as an enum for the megaavr processors such as the atmega4809 used on the Uno WiFi Rev2. You have to use HIGH or LOW instead of a numeric value.

pert:
Open C:\Users\caxpo\Documents\Arduino\libraries\NewLiquidCrystal_lib\LiquidCrystal.cpp in a text editor.

Change line 137 from:

digitalWrite( _rs_pin, ( mode == LCD_DATA ) );

to the corrected code @TheMemberFormerlyKnownAsAWOL provided:

digitalWrite( _rs_pin, ( mode == LCD_DATA ) ? HIGH : LOW);

Save the file.

Your sketch should now compile without that error.

This work, thank you :slight_smile:

You're welcome. I'm glad to hear it's working now. Enjoy!
Per