How can I connect simulink with Arduino Mega2560 ?

조회 수: 10 (최근 30일)
xuan hoa
xuan hoa 2021년 11월 26일
답변: Samhitha 2025년 8월 29일
I am using matlab R2021b and arduino mega2560 , I have designed 1 simple project up and running , but simulink gave error like below :
Anyone help me. Thanks

답변 (1개)

Samhitha
Samhitha 2025년 8월 29일
There is a Simulink External Mode connection issue between MATLAB R2021b and Arduino Mega 2560. Here are few ways to resolve it
1.Check the COM Port:
  • Make sure your Arduino is connected to the correct COM port.
  • In Simulink, go to Hardware Settings > Target Hardware Resources > Host-board connection > Set the correct COM port (it should match the one in Device Manager).
2.Close Other Serial Connections:
  • The Arduino IDE Serial Monitor, or another application may be using the COM port.
  • Close the Arduino IDE and make sure only MATLAB/Simulink is using the COM port.
3.Baud Rate Mismatch
  • By default, Simulink external mode uses 115200 baud.
  • If you manually change it in the model or Arduino, make sure both matches. Arduino must be compiled with the same baud rate.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by