Go Down

Topic: need help with GUI user input to serial string to arduino (Read 557 times) previous topic - next topic

doulos24

Jan 31, 2013, 07:01 pm Last Edit: Jan 31, 2013, 07:35 pm by doulos24 Reason: 1
I need to make a small GUI that allows me to format 3 values then create a string and send that string to the serial port of an arduino mega2560.

I already tried and failed using autohotkey and a custom serial script package that was to buggy to work  :(

so my code needs to be something like this.

pseudocode  

prompt1 "enter # of pulses"
save input to var1
prompt2 "enter "pulse width in ms"
save input to var2
prompt3 "enter delay in ms"
save input to var3

string = "%var1%,%var2%,%var3%"

send %string% to arduino at (9600)
so it would send say 1000.14.14 to the serial port of the arduino

on the arduino side I'm using the function Serial.parseint();

so the arduino would parse the string into 3 variables
x= 1000
y = 14
z = 14

the arduino end is working already with the serial monitor or putty

i just need to make a clean small gui that can send serial!  

any advice on how to accomplish this quickly?

thanks
doulos

 

HazardsMind

Simple, but do you know how to read in a single character? If you do then just put the incoming characters in an array, not a string, (you can but strings are highly NOT recommended). After each prompt, get the data, store it in an array then change the array. You can use a 2D array as such, "My_Array[10][3]"

My_Array[data_count][switch_count] = var;

Everytime you enter a new char, you update the data_count and store the new character. Then once you get everything from the first prompt, update switch_count, and repeat. Second prompt, repeat.

Or same idea but with seperate arrays, Array1[], Array2[], Array3[].
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

PaulS

I have a Windows forms application, written in C# that you could add text fields and labels to. Remove the existing text entry field, and change the send button to get data from all three fields to send. If you are interested, PM me with an e-mail address and I'll send it to you.

Go Up