Arduino Due同士の通信・シ​リアル通信を用いて送​信した文字が受信側で​うまく表示されない

31 views (last 30 days)
mochi
mochi on 12 Oct 2022
Arduino Due同士でシリアル通信をさせたいです.
送信側Arduinoはmatlabで,受信側ArduinoはArduino IDEでプログラムします.
そこで送信側Arduinoには以下のプログラムを書きました.
device = serialport("COM3",9600);
for i=1:2000
i
pause(20);
write(device,"1000","int8");
end
受信側Arduinoには以下のプログラムを書きました.
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int incomingByte = Serial1.read();
Serial1.println("number");
Serial1.println(incomingByte);
int b = incomingByte +2;
Serial.println(b);
}
}
受信側Arduinoのシリアルモニタで結果をみたところ,100010001000と改行されてない結果が羅列されていくだけで
bの値も表示してくれません.
どのようにすればよいでしょうか.

Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!