MATLAB abd Arduino UNO serial comm.(LED blinking)

版本 1.0.0.0 (159 字节) 作者: MATuino R
LED connected to pin 13 of arduino uno will be controlled using serial communication from MATLAB .
1.5K 次下载
更新时间 2014/7/31

查看许可证

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);
}
}
}

引用格式

MATuino R (2025). MATLAB abd Arduino UNO serial comm.(LED blinking) (https://ww2.mathworks.cn/matlabcentral/fileexchange/47418-matlab-abd-arduino-uno-serial-comm-led-blinking), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0