Matlab GUIDE Display Temp Sensor Data
5 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Geoff Hayes
on 19 Apr 2014
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 Comments
Geoff Hayes
on 19 Apr 2014
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.
See Also
Categories
Find more on Block Libraries 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!