unable to receive data in arduino from matlab

3 ビュー (過去 30 日間)
Sravani Vanama
Sravani Vanama 2019 年 11 月 19 日
コメント済み: Walter Roberson 2019 年 11 月 20 日
I have tried to send integer from matlab to arduino
my matlab code is
clc;
clear all;
close all;
s=serial('COM4','BAUDRATE',9600);
fopen(s);
fprintf(s,'%i',1);
fclose(s);
and my arduino code is
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0)
{
int b=Serial.read();
if(v==1)
{
Serial.println(v);
}
else
{
Serial.println(v);
}
}
}
After uploading it to arduino uno and clicking on serial monitor i am not getting any output. its just blank
Is there any mistake in my code or my connectivity process??
  5 件のコメント
Sravani Vanama
Sravani Vanama 2019 年 11 月 20 日
編集済み: Sravani Vanama 2019 年 11 月 20 日
I am new to matlab. I am not able to understand what u have said.
Can you please tell me lines where code should be modified clearly??
I have even tried this way......then i am getting 'none' printed infinite times in serial monitor
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0)
{
int v=Serial.read();
Serial.println(v);
}
else
Serial.println("none")
}
which means Serail.available() is not greater than 0.
Walter Roberson
Walter Roberson 2019 年 11 月 20 日
s=serial('COM4','BAUDRATE',9600);
fopen(s);
fwrite(s, uint8(1));
fclose(s);

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB 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