Saturday 5 July 2014

MATLAB & ARDUINO : LED blinking

The last post(1st Jul 2014) which elaborates about the digitalWrite function , which is utlised for togglin the LED connected to PIN 13 of arduino uno using MATLAB environment. In this post,we have resolved the problem of typing the function( digitalWrite) in COMMAND WINDOW over and over again to toggle the LED. By compiling a small LED blinking program written in MATLAB script, this program will blink the LED for 60 seconds. After all prerequisite program installed in Arduino IDE and MATLAB ,you can directly run this program and blink the LED through MATLAB programming. To make it more fun you can use other toolbox of MATLAB like image processing or signal processing to trigger the LED or any actuator.

To get better understanding, watch a video named MATLAB & ARDUINO : LED Blinking on our youtube  channel  MATuino R.



The MATLAB programming for LED blinking:

a=arduino('COM3');              % Establish serial communication via COM3 port
pinMode(a,13,'output');         % Assigning pin 13 of arduino as output pin.
tic

while toc/60 < 1                % toc/60 means the while loop will keep
                                 executting  till 60 seconds.
                                    
digitalWrite(a,13,1);           % write a boolean 1 on pin 13 of arduino

pause(1);                        %Pause the execution for number of seconds                                                                mentioned in bracket.
    
digitalWrite(a,13,0);           % write a boolean 0 on pin 13 of arduino
pause(1);

end


Make sure for above program select the correct COM port as in our case it is COM# , it may be something else in your case.
Thank you for any further query comment on this post. 

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...