Tuesday 1 July 2014

MATLAB & ARDUINO interfacing - digitalWrite(LED)

This post is a follow up of the 28th June post i.e MATLAB & ARDUINO interfacing - Part#1, which was about downloading required MATLAB support file for arduino IDE. This post will elaborate about uploading desired program on UNO and preparing MATLAB environment before establishing communication between arduino uno and MATLAB  and also a  demonstration of simple digitalWrite function by toggling the LED.
The steps involved for completing the communication between MATLAB and Arduino uno are:

1. Open Arduino IDE and open the "pde" named file in examples , then select a file named "adioes" and upload this program on arduino uno. It will take few seconds and blinking of  LED on UNO borad will confirm the uploading.

2. Then open the MATLAB environment , make sure that the current folder selected will be the MATLAB  support folder for arduino named "ARDUINO IO" and then create a serial connection of MATLAB with arduino uno using command

>> a= arduino( COM X);              here X is the number assigned to the port of your PC or laptop.

3. After successful connection with arduino , assign a pin 13 as a output pin using "pinMode" command and after that, write a Boolean 1 or 0 to pin 13 for toggling the LED connected using "digitalWrite"
command.

The final demo looks like the image below:
LED toggling using MATLAB

The final commands for digitalWrite are as under , type each command at a time in COMMAND WINDOW of MATLAB enviornment.

a=arduino('COM3');            % Establish serial communication via COM3 port
pinMode(a,13,'output');       % Assigning pin 13 of arduino as output pin.
digitalWrite(a,13,1);         % write a boolean 1 on pin 13 of arduino (LED ON)
digitalWrite(a,13,0);         % write a boolean 0 on pin 13 of arduino (LED OFF)
 
For further detailed and step by step description of the above post visit youtbe and visit our channel
"MATunio R"
And do watch video related to this post

MATLAB&ARDUINO interfacing - digitalWrite(LED)

For any query post a comment on this post or mail us at arduinomatlab@gmail.com. 

No comments:

Post a Comment

Browse and display image in MATLAB

First of all, excuse us for not posting any tutorial and videos on our you tube channel for such a long time. Recently one of our subscrib...