I want to make a GUI have a slider, this slider’s value will be used to transmit serial data to PIC microcontroller.
The output value of the slider must be a character or string.
-
How can I define enter code here variable in matlab gui?
-
How can I know the type of output value of slider ? (int, char, …)
code:
s=serial('COM7');
slider_value = get(handles.slider3, 'value');
fopen(s);
fprintf(s,'%s',slider_value);
fclose(s)
Useful information: http://www.mathworks.se/help/techdoc/ref/uicontrol_props.html.
The type of the
Valueproperty is the scalar value it currently has. This value will betweenMinandMaxwhich defaults to 0 and 1, respectively. Did you set these to other values? The scalar value will likely be in double representation so you need to convert to a string:Put this in your init-section (a slider that goes from 0 to 100):
And this in your callback routine:
The above is just an example. You should set
Min,Max, andSliderStepto what you want. Find the relevant sections in the UIcontrol properties documentation that I link to in the beginning. You should also note that I send the data as an unsigned 32-bit value (not the recast).