Problem with Simulink/coder to use LCD 1602 display

7 visualizaciones (últimos 30 días)
Hi there,
I'm trying to write a Simulink block to use with Arduino an LCD 1602 driven through the I2C port. What I would like to obtain is to be able to display some text on the LCD display connected to my Arduino Uno:
I have already written a custom block to drive with Arduino the internal LED, and it works fine (see
I wanted to use the same approach to write a driver for the LCD 1602 display, but I am struggling to let the coder to compile my .cpp program. In particular I get the following error (and may others...) which is generated by the file:
In file included from /home/scorretti/Documents/MATLAB/SupportPackages/R2023a/3P.instrset/arduinoide.instrset/arduino-1.8.19/hardware/arduino/avr/cores/arduino/Print.h:27:0,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/libraries/LiquidCrystal_I2C.h:6,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/include/lcd1602.h:6,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/demo_lcd_1602_ert_rtw/demo_lcd_1602.h:27,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/demo_lcd_1602_ert_rtw/demo_lcd_1602_data.c:20:
/home/scorretti/Documents/MATLAB/SupportPackages/R2023a/3P.instrset/arduinoide.instrset/arduino-1.8.19/hardware/arduino/avr/cores/arduino/Printable.h:25:1: error: unknown type name 'class'; did you mean 'labs'?
class Print;
Up to my understanding, the problem is that the compiler is trying to compile the file Print.h like if it were written in C instead of C++, and I cannot figure out why and how to fix this.
It is not possible to configure the project so as to use C++
My C++ code (lcd1602.cpp) is basically a copy/paste from an Arduino sketch (Sketch_1_1_Display_the_string_on_LCD1602.ino) which uses the same library, but compiles and runs fine.
Similar topics / examples may be:
The last question seems really close to the problem I'm facing, but I could not solve it as well.
Any help is appreciated.

Respuesta aceptada

Riccardo Scorretti
Riccardo Scorretti el 9 de En. de 2024
Actually I solved myself the problem. In case it may be useful to someone:
  • problem: the file LiquidCrystal_I2C.h was included from lcd1602.h.
  • solution: this file is included from lcd1602.cpp, and the file LiquidCrystal_I2C.cpp has to be added to the list of files to be compiled (see the method updateBuildInfo)
Surely this is not the most elegant method, but it seems to work. The fixed program and a demonstration Simulink project are available (I apologize for inelegant and/or uncorrect features of my model and programs).

Más respuestas (0)


Más información sobre Arduino Hardware en Help Center y File Exchange.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by