Printing numbers and letters to I2C LCD using serial communication
Afficher commentaires plus anciens
Hi everyone,
I'm currently using an Arduino Uno with a I2C LCD hooked up to it. I've browsed through a bunch of the posts and have tried numerous strategies to get my I2C display to display numbers and a string. Anything I output is just giving me whole numbers like 100, 101, 110 etc. I'm not getting any text at all. What I would like it to display on my LCD Screen is "Heart Rate: 79.95"
Here is what I have:
arduino=serial('/dev/tty.usbmodem14101','BaudRate',9600);
fopen(arduino);
heartrate=79.95;
fprintf(arduino,'Heart Rate: %d\n',heartrate);
fclose(arduino);
I've varied fprintf (ex: fprintf(arduino,'%.2f',heartrate)) to just print a decimal number and it also won't do it, I still get whole numbers.
Any ideas?
Réponse acceptée
Plus de réponses (1)
MathWorks MATLAB Hardware Team
le 8 Déc 2023
Modifié(e) : MathWorks MATLAB Hardware Team
le 8 Déc 2023
0 votes
Hi,
You can utilize the MATLAB Support Package for Arduino hardware along with an LCD addon in order to display the required characters.
For additional information, please refer to the following links:
- https://in.mathworks.com/help/supportpkg/arduinoio/ug/add-lcd-library.html (This can be used to create an I2C LCD addon)
Thank you,
MATLAB Hardware Team
MathWorks
2 commentaires
Phan Tien Manh
le 8 Déc 2023
when i write:
s = serialport("COM5",9600)
it always shows this error:Unable to connect to the serialport device at port 'COM5'. Verify that a device is connected to the port, the port is not
in use, and all serialport input arguments and parameter values are supported by the device.
See related documentation for troubleshooting steps.
Why ?
MathWorks MATLAB Hardware Team
le 11 Déc 2023
Hi,
You can verify the availability of the COM5 port by using the Device Manager in Windows or by executing >> serialportlist('available') in MATLAB.
Once you have confirmed this, you can proceed with the troubleshooting steps outlined in the following link.
Also feel free to contact MathWorks Technical Support to get help on resolving this issue.
Thanks,
MATLAB Hardware Team
MathWorks
Catégories
En savoir plus sur MATLAB Support Package for Arduino Hardware dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!