Uploaded by Apoorva

MatlabOnArduino (1)

advertisement
Introduction of matlab on
arduino
• In order to use arduino in matlab the following
libraries to be installed
MATLAB Support Package for Arduino Hardware
• In case of Simulink
Simulink Support Package for Arduino Hardware
The following steps required to install those libraries
are
Step1- Go to home and click ADD ONS
Step 2 - In ADD ONS search for required libraries
mentioned before
NOTE - Once installation of package in done we need to
specify how the arduino is connected to the laptop and
also the type of board which will be used and the port as
well
STEP 3 - Once the complete installation is done open
matlab
In order to use arduino and matlab a specific command
must be used
Syntax - arduino('PORT','type of board used');
Example a = arduino('COM3','Uno');
Some of the basic commands which can be used are
commands
1) configurePin
Syntax
pinMode = configurePin(a,pin)
configurePin(a,pin,mode)
Example
Inital condition
a = arduino('COM4','Uno');
configurePin(a,'D1')
After changing
a = arduino('COM4','Uno');
configurePin(a,'D1','DigitalInput');
pinMode = configurePin(a,'D1')
2) readDigitalPin Syntax
value = readDigitalPin(a,pin)
a = arduino;
readDigitalPin(a,'D13')
3)writeDigitalPin Syntax
writeDigitalPin(a,pin,value)
writeDigitalPin(a,'D5',1);
4)To read voltage Syntax
voltage = readVoltage(a,pin)
In order to know more about different commands to link
arduino and matlab you can visit this website
https://in.mathworks.com/help/supportpkg/arduinoio/ge
t-started-with-matlab-support-package-for-arduinohardware.html?s_tid=CRUX_lftnav
THE
END
Download