MATLAB: App Designer and Arduino

app designerarduino

Hi,
I am designing an interface in the App Designer. I have an Arduino board connected to some sensors. I would like to be able to run the interface multiple times, but right now I run it once perfectly and when I click run again it tells me I have an existing connection at my COM port and I need to clear it. I am unsure how to do this as I am very new to app designer! Any help would be greatly appreciated!
Thanks!

Best Answer

You could try changing your startup to just this instead.
function startupFcn(app, a)
app.a=arduino(app.port,'uno');
end
Now remove the arduino(app.port,'uno'); line from your RUNButtonPushed(app, event) function.
This way you only create the arduino object once when you startup the app and then after that all you do is send signals with the button. I do not have an arduino nearby to test this on unfortunately.