- https://www.mathworks.com/help/simulink/supportpkg/arduino_ref/getting-started-with-arduino-hardware.html
- https://www.mathworks.com/help/simulink/supportpkg/arduino_ref/read-temperature-from-an-i2c-based-sensor-using-arduino-hardware.html
- https://www.mathworks.com/help/simulink/examples.html?category=supportpkg-arduino&s_tid=CRUX_topnav
How do I translate an ARDUINO IDE Code to Simulink blocks?
조회 수: 9 (최근 30일)
이전 댓글 표시
We are required to program an Arduino using simulink blocks as part of a university requirement.
It wasn't really taught to us in-depth, and most resources I was able to find didn't go deeper than programming an LED light to blink.
I did install the Arduino support package and I've finished coding using Tinkercad and was wondering how do I translate this to simulink. External resources are appreciated.
If you're wondering, this is the project: https://www.tinkercad.com/things/69Q0a1ZcKaE-morse-code-translator
How it works is there are 3 buttons which I'll refer to as Button 1,2,3 from left -> right.
It starts by pressing Button 3 which acts as a start/restart button. The red flashing LED indicates that the board is ready to receive further instructions.
Button 2 is pressed for a period of time to represent the dots and dashes, holding the button for 200ms or less indicates a dot, and pressing for more than that represents a dash. A buzzer gives feedback indicating the button is being pressed.
Button 1 is pressed after you've set the character using button 2 to appear on the I2C.
After being idle for 3 seconds, a the yellow LED lights up indicating that the next character will have a space before it.
Other features include skipping to the next line once 16 characters in inputted and resetting after 32 characters are inputted.
The code is taken from https://www.hackster.io/492608/morse-code-converter-bec9a9 which I optimized due to some problems, e.g. spaces inputting at incorrect time, double spacing, ending the line in a space requires a reset.
I'll be sure to answer any questions you might have. Thank you in advance.
댓글 수: 0
답변 (1개)
Suman
2024년 6월 20일
Hi Nathan,
It is not possible to automatically convert Arduino code to an equivalent Simulink model. You need to take a manual approach. As per my understanding the goal here to to create a Simulink model that interacts with Arduino in the same way the code does.
To do that, you can utilize the blocks provided by the Simulink Support Package for Arduino Hardware as well as the common Simulink blocks to implement the logic equalvalent to the Arduino code.
Please go through these examples to see how Simulink is used to interact with Arduino hardwares:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Modeling에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!