GUI interface with arduino

25 views (last 30 days)
Tee on 24 Mar 2011
Commented: Mohamed Asif on 6 Jul 2017
now, i try to control arduino board through Matlab GUI(using IO packages). First,i try to light on the LED by click on the push button i create, below is the callback function i put:
after i try it, the LED only blink for a second, but now i wish to light on the LED continuously, what code should i type? I wish to light on and light off the LED using push button i create...anyone can help me, thanks..
  1 Comment
Mohamed Asif
Mohamed Asif on 6 Jul 2017
use this above link you can get idea about it

Sign in to comment.

Accepted Answer

Jarrod Rivituso
Jarrod Rivituso on 24 Mar 2011
Disclaimer - I've used Arduinos in the past, but never used the MATLAB Arduino package.
With that said, I'm not sure if this is your issue, but one thing to consider is whether you want your callback to reinitialize the Arduino pinmode every time.
It seems to me like you'd really want to set up the Arduino pin modes and COM ports in the GUI initialization, and then have your callback only perform the digitalWrite.
If using GUIDE, then you will find a GUI initialization function that you can use to do the initialization. Then, you can use the guidata function to add the Arduino object to the guidata. Something like...
a = arduino('com3');
handles.a = a;
guidata(hObject, handles);
Then, you could use the handles structure again in your callback
Again, this is all assuming you are using GUIDE. If you aren't, then you probably know your GUI's initialization better than I do.
medo on 28 Jul 2014
hi all .... please i need the correct arduinoIO because iam downloading it but it not woke >>> thanx to all

Sign in to comment.

More Answers (2)

Kaustubha Govind
Kaustubha Govind on 24 Mar 2011
You could try using a persistent variable to store that last state, and toggle that each time the callback is fired:
persistent ledValue
if isempty(ledValue)
ledValue = 0;
ledValue = ~ledValue; %toggle ledValue
heisenberg on 18 Mar 2015
how to access serial pins in above program to send data?

Sign in to comment.

hardik sanghvi
hardik sanghvi on 25 Nov 2015
How to make pause and counter button code


Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!