File Exchange

image thumbnail

MATLAB abd Arduino UNO serial comm.(LED blinking)

version 1.0.0.0 (159 Bytes) by MATuino R
LED connected to pin 13 of arduino uno will be controlled using serial communication from MATLAB .

7 Downloads

Updated 31 Jul 2014

View License

A serial communication is established between arduino uno and MATLAB and the LED on pin 13 of arduino uno can be toggled using number '100' and '101'. Before executing this .m-file ,make sure the following code below is uploaded on arduino UNO:
Note: Make sure the COM port number is correctly entered in MATLAB program

const int ledpin=13;
int recValue;

void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}

void loop()
{
if(Serial.available()>0)
{
recValue=Serial.read();

if (recValue == 100) // If use will send value 100 from MATLAB then LED will turn ON
{
digitalWrite(ledpin, HIGH);
}
if(recValue == 101) // If use will send value 101 from MATLAB then LED will turn OFF
{
digitalWrite(ledpin, LOW);
}
}
}

Cite As

MATuino R (2020). MATLAB abd Arduino UNO serial comm.(LED blinking) (https://www.mathworks.com/matlabcentral/fileexchange/47418-matlab-abd-arduino-uno-serial-comm-led-blinking), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

how to give serial read value as 100 in push button call back so that i can use my button as input instead of typing in keay board, can you please tell me?

Thanks you

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux