필터 지우기
필터 지우기

help with matlab arduino question

조회 수: 1 (최근 30일)
Jihad Chamseddine
Jihad Chamseddine 2015년 5월 9일
댓글: Walter Roberson 2015년 5월 11일
I have a complete program on Arduino, I just want when I click a push button on a matlab gui that the program in Arduino will run, hope somebody can help me please...

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 9일
It appears that it is possible. You need to take some steps to save the generated sketch before hand. Then you can have your GUI send the sketch to the device in order to start it running. See
I have not investigated arduino enough to know how to remotely control it to stop a sketch running afterwards.
Depending on your purposes, you might find it easier to instead have the sketch already loaded (e.g., use the tools to prepare and automatically upload it), but to have it programmed to wait for input before it proceeds with its main purpose.
  댓글 수: 3
Paul
Paul 2015년 5월 11일
Cheers for the link. It's clear I need to clean up that solution and maybe make a a little program for the community.
With regards to stopping a sketch:
Presumably a serial connection is involved. If it is, then some Arduino's will stop on their own when the serial connection has been terminated on the PC end. This can be good or bad. Seems to occur with the Inland Arduino's from Microcenter.
However what I rely on is sending serial commands to the Arduino. In your Arduino sketch, you just need to add to your loop a quick check to see if there is anything in the serial buffer. If there is, read it and parse it. If it has your "start" or "stop" command, you react accordingly. It would be best if you are changing the run state, not a hard command. Then in your Arduino loop you can have
void loop()
{
readSerial()
if runMode == 1
// Your run code, one loop
else
// Delay to not tax the Arduino too much
delay(100)
end
} // end of void loop()
Walter Roberson
Walter Roberson 2015년 5월 11일
Thank you, Paul.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 5월 9일
Just search the forum for arduino by clicking the tag above.
  댓글 수: 3
Image Analyst
Image Analyst 2015년 5월 9일
Sorry, no. I have an arduino but I haven't found time to play around with it in MATLAB yet.
Jihad Chamseddine
Jihad Chamseddine 2015년 5월 9일
ok thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by