Hi all if you are a beginner or wants to try different programming methods , here a guide to show you how to program Arduino from Matlab simulink, a powerful graphical programming language which is used in industries. In this tutorial you will learn about how to blink an LED using Arduino and programming from Matlab Simulink. before starting this tutorial check out the introduction section to know about what are the needs to get started with this tutorial and how to install the software and hardware requirements.
Check out the above video to know how to program which is explained in step by step manner.
Steps to make the LED blink
Connect your LED to the 3rd Pin or any other pin you would like and connect your Arduino to your Laptop or PC
Start your Matlab
Click on the Simulink Library.
Once the library browser opened click on the New model from the simulink library.
after the new model window open save your new model by giving any name you like and click on the Simulink support Package for Arduino Hardware from the Simulink library Browser
Open the Common box in the library and choose Digital Output block , drag and drop the digital output block in the model window.
Double click on the Digital Output block and change the pin number to whatever pin number the LED has connected in this case I have connected my LED to the 3rd pin of Arduino Mega
after completing the above steps, got the library browser and select sources from the browser, after opening the sources blocks click the signal generator block and drag it to model window and connect the signal generator to the digital output block by pointing the arrow towards the digital output from signal generator.
Double click on the Pulse generator change the Time(t) to pulse type to sample based.
and also change the sample time to 0.01 and click OK to close the pulse generator parameters.
Change it to external connector and also the simulation time to infinite.
click the tools and select run on target and choose prepare to run. once the window opens click on the Enable hardware specification and from the Hardware board select Arduino Mega
choose the board and click ok, once you pressed ok it will move to the device details don't change any parameters leave everything as same and click ok.
click the run button to temporarily run your code on Arduino which allow us to verify the program if you are not satisfied with the result you can go and change the code until get the desired results and if the program is perfect you can permanently deploy the code by just pressing the deploy to hardware button available in the Model window.
To be Continued...