Print in LCD I2C Arduino in matlab

조회 수: 5 (최근 30일)
Khaled Al-Faleh
Khaled Al-Faleh 2017년 4월 25일
Hi guys, I have a code in arduino and I want to run it by using matlab which display message I'm using arduino lcd i2c and here is my code in arduino please I need to solve this issue .. or can I load my arduino code file in matlab and use it ?
//load libraries
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//Define variables
#define I2C_ADDR 0x3F //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
//Initialise the LCD
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
//Define the LCD as 16 column by 2 rows
lcd.begin (16,2);
//Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
//goto first column (column 0) and first line (Line 0)
lcd.setCursor(0,0);
//Print at cursor Location
lcd.print("Finally!");
//goto first column (column 0) and second line (line 1)
lcd.setCursor(0,1);
lcd.print("Work :)");
}
void loop(){ }
  댓글 수: 1
Justin Primero
Justin Primero 2019년 6월 9일
Have you solved this issue? If yes, I'd like to know how. Thanks.

댓글을 달려면 로그인하십시오.

답변 (2개)

Aravind
Aravind 2025년 6월 26일
You can control the LCD display connected to an Arduino by using the Arduino-specific LCD display library. While this library is not directly available in Simulink, it can be integrated using the "IO Device Builder" app.
The "IO Device Builder" app, which is part of the "Simulink Support Package for Arduino Hardware," allows you to incorporate custom or third-party C/C++ source files as a System object, which then appears as a block in Simulink.
By using the "IO Device Builder" app, you can create a block that communicates with the LCD display connected to your Arduino. Once you deploy the model to the Arduino, it will be able to communicate with the LCD display via I2C.
For more details on the "IO Device Builder" app, you can refer to the following documentation: https://www.mathworks.com/help/simulink/arduino-io-device-builder.html.
Additionally, here are a few tutorials to help you get started with the "IO Device Builder" app:
  1. Getting started - https://www.mathworks.com/help/simulink/supportpkg/arduino_ug/io-device-builder.html
  2. Interfacing DHT11 sensor with Arduino using IO Device Builder - https://www.mathworks.com/help/simulink/supportpkg/arduino_ref/dht11-relative-humidity-temperature-io-device-builder.html
  3. Interfacing ADXL343 sensor with Arduino - https://www.mathworks.com/help/simulink/supportpkg/arduino_ref/adxl343-read-acceleration-io-device-builder.html
I hope this resolves your query!

MathWorks MATLAB Hardware Team
MathWorks MATLAB Hardware Team 2025년 7월 4일
Hi,
While you cannot directly run your existing Arduino code (.ino file) from MATLAB, you can leverage the custom Arduino library support available in the MATLAB Support Package for Arduino Hardware to integrate your I2C LCD display.
The LCD ADDON example can be referred to create the customized LCD Library which will help you in acheiving your use case.
Contact MathWorks technical support team if you face issues while creating library
https://www.mathworks.com/support/contact_us.html
Thanks,
MATLAB Hardware Team
MathWorks

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by