how to send a single integer value from Matlab to arduino?

17 vues (au cours des 30 derniers jours)
Tarique Anwar Mulla
Tarique Anwar Mulla le 28 Mai 2019
Modifié(e) : Ashitha Nair le 12 Fév 2020
I want to send it via Serial Communication

Réponses (1)

Ashitha Nair
Ashitha Nair le 11 Fév 2020
Modifié(e) : Ashitha Nair le 12 Fév 2020
Your matlab code could be as follows
s = serial('COM8','BaudRate',9600); %creates a serial object
flushinput(s) %this discards all previous s values
fopen(s);
fwrite(s,255); % allows you to send a single int here, I'm sending 255
This should be paired with a read method, in your arduino IDE. Make sure that you type in the correct COM port and baud rate. Baud rate should be the same (in your serial object as well as the arduino).

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by