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

조회 수: 17 (최근 30일)
Tarique Anwar Mulla
Tarique Anwar Mulla 2019년 5월 28일
편집: Ashitha Nair 2020년 2월 12일
I want to send it via Serial Communication

답변 (1개)

Ashitha Nair
Ashitha Nair 2020년 2월 11일
편집: Ashitha Nair 2020년 2월 12일
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).

카테고리

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