Matlab GUIDE Display Temp Sensor Data

9 ビュー (過去 30 日間)
Leah
Leah 2014 年 4 月 19 日
コメント済み: Geoff Hayes 2014 年 4 月 19 日
Hello,
I'm working on a project where I need to take the ambient temperature via a temp sensor connected to an arduino, and display it on a GUIDE created interface. Is there a way to simply display the temperature from the sensor in a text box? (e.g. "75.4") Most of the forums only have it displayed graphically.
Thanks!

回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 4 月 19 日
Hi Leah,
If you have the handle to the text box, then you can simply set the string text within that box to your temperature:
set(txtBoxHandle,'String', num2str(tempVar));
The handle to the text box should be relatively easy to obtain. Hope this helps!
Geoff
  2 件のコメント
Leah
Leah 2014 年 4 月 19 日
Is the text box handle obtained in GUIDE or in the .m file?
Geoff Hayes
Geoff Hayes 2014 年 4 月 19 日
The text box handle is determined at run time and can be accessed in the *.m code. If you look in the code, you should see several functions that are auto-generated and have as (usually) the last input a parameter called 'handles'. It is within this structure that you can get the handle to the text box as follows: when a widget (button, text box, edit box, etc.) is added to the GUI, one of its properties is called Tag. This tag is usually auto-generated with the type of the widget and the number. So if you add a third text widget to your GUI, its tag may be something like 'text3'. (You can change this to whatever you want though.). But you use this tag to get the handle in the code: handles.text3
It may be a little more tricky to get the handle if your update function doesn't have the handles input parameter but it can still be done.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB 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