26/5/2015
Arduino+MATLAB = MATuino: MATLAB & ARDUINO serial communication
3
mais
Prximo blog
Criar um blog
Login
Arduino+MATLAB = MATuino
This blog is basically a platform for sharing knowledge about interfacing of world's first open source
hardware ARDUINO with MATLAB and making variety of projects using ARDUINO+MATLAB or
ARDUINO or MATLAB.
Thursday, 10 July 2014
MATLAB & ARDUINO serial communication
I have being asked by many people about interfacing Arduino UNO with MATLAB without using
any supporting inbuilt functions. So , for answering all those queries I am posting this article by
explaining MATLAB & Arduino UNO serial communication .
This post will cover the topic of controlling arduino pin13 LED by send serial command
from MATLAB to arduino UNO.
The Arduino code required for establishing the serial communication and reading serial data is.
Google+ Followers
const int ledpin=13;
MATuino R
int recValue;
Add to circles
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
if(Serial.available()>0)
{
27 have me in circles
recValue=Serial.read();
if (recValue == 100)
// If use will send value 100 from MATLAB
then LED will turn ON
View all
About Me
MAT uino R
Follow
digitalWrite(ledpin, HIGH);
}
if(recValue == 101)
// If use will send value 101 from MATLAB
then LED will turn OFF
{
digitalWrite(ledpin, LOW);
}
}
}
27
MATuino R is a
youtube tutorial
channel for sharing
knowledge about interfacing of
world's first open source hardware
ARDUINO with MATLAB and
making variety of projects using
ARDUINO+MATLAB or ARDUINO
or MATLAB.
This channel is also associated with a
blog
http://matlabarduinorobotics.
blogspot.in/
View my complete profile
Blog Archive
2015 (1)
2014 (14)
August
(1)
July (8)
Arduino
INDIA
call for
interns
!
MATLAB
GUI for
image
type
http://matlabarduinorobotics.blogspot.in/2014/07/matlab-arduino-serial-communication.html
1/3
26/5/2015
Arduino+MATLAB = MATuino: MATLAB & ARDUINO serial communication
convers
ionPart2
MATLAB
GUI
designi
ng
using
GUIDE
for
image
type
co...
MATLAB
GUI
Arduin
o LED
blinkin
g
MATLAB
&
ARDUI
NO
serial
commu
nicatio
n
Upload the above program on Arduino UNO and then open MATLAB environment for
establishing serial communication with UNO.
The MATLAB code required for establishing communivcation and sending required command for
toggling LED is:
s=serial('COM','BAUD', 9600); % Make sure the baud rate and COM port is
% same as in Arduino IDE
fopen(s);
for m=1:10
% The program will execute 10 times ,
%you can change the vaalue of m to increase or decrease
%the number of executions
servalue= input('Enter the value 100 to turn ON LED & 101 to turn OFF LED :');
fprintf(s,servalue);
%This command will send entered value to Arduino
end
New
membe
r in
ARDUI
NO
family:
USB
Host
Shield
MATLAB
&
ARDUI
NO :
LED
blinkin
g
MATLAB
&
ARDUI
NO
interfac
ing digital
Write(L
ED)
June (5)
After opening the MATLAB execute this program, initially a LED on PIN13 on Arduino UNO will
blink that denoted handshaking or serial communication establishment between UNO and
MATLAB . Then MATLAB will ask user to enter desired value, make sure to enter 100 to turn ON
and 101 to turn OFF LED.
Note: Make sure the baud rate and COM port entered in MATLAB code is similar to the one in
Arduino IDE
For any further query commen on this post or post your question on
Google+ account name MATuino R
https://plus.google.com/u/0/106198205604943884729/posts
Facebook community page arduinomatlabrobotics
https://www.facebook.com/arduinomatlabrobotics?ref=hl
http://matlabarduinorobotics.blogspot.in/2014/07/matlab-arduino-serial-communication.html
2/3
26/5/2015
Arduino+MATLAB = MATuino: MATLAB & ARDUINO serial communication
Posted by MATuino R at 1 3:49
+3 Recomende isto no Google
3 comments
Add a comment as neemias monteiro
Top comments
MATuino R 10 months ago - Shared publicly
MATLAB & ARDUINO serial communication
I have being asked by many people about interfacing Arduino UNO with MATLAB without
using any supporting inbuilt functions. So , for answering all those queries I am posting this
article by explaining MATLAB & Arduino UNO serial communication . ...
+1
2
1
1 Reply
MATuino R via Google+ 10 months ago - Shared publicly
MATuino R originally shared this
MATLAB & ARDUINO serial communication
I have being asked by many people about interfacing Arduino UNO with
MATLAB without using any supporting inbuilt functions. So , for answering all
those queries I am posting this article by explaining MATLAB & Arduino UNO
serial communication . ...
1 Reply
Ethan Thibaudeau 3 months ago (edited) - Shared publicly
Thank you! I've been trying to get this to work with ANSI formatting, but it would only work
sending characters, not numbers. fprintf(s,'%c/n','a') would work, but fprintf(s,'%d/n',1)
would not. fprintf(s,1) will be read correctly by the Arduino with Serial.read().
1 Reply
Newer Post
Home
Older Post
Subscribe to: Post Comments (Atom)
Simple template. Powered by Blogger.
http://matlabarduinorobotics.blogspot.in/2014/07/matlab-arduino-serial-communication.html
3/3