- Windows 7 with Visual Studio 2012 Express. - Coding in C#. - Arduino UNO providing serial inputs to the computer (via USB). - Flexiforce Pressure Sensor plugged into the Ardiuno (and working).
So here is what my interface in the C# program looks like, with the names of the items beside it:
And here is the code I have at the moment:
That is the cleanest I can make it look. I have tried many, many tutorials and pieces of code, but I just cannot get my head around how to get continual reads of the information coming off the serial port, and make it relate to anything in my C# program.
So I thought I'd just see if I could get continual reads into the ForceTextbox, once the GetForceButton is pushed.
Can anyone help me with what code needs to go into the private void GetForceButton_Click section, so that the reads from the serial port are populating the ForceTextbox?
Do you have to send a Do you have to send a command to get the arduino to give a measurement? My laptop is in work just now, so i cant post code till tomorrow but i see there could be three ways this could go. 1 you have to send something to get a response, so serial.write(“the command goes here”); set a flag to say waiting for response. Parse the response in the recieved handler, update the progress bar.
2 the arduino sends data constantly? Does it add a newline after the data? In the recieved handerler you can use serial.readline() until it returns a null, parse data and display.
3 the data comes continuously without a lime ending, repeat until serial.read returns null, mybuffer+=serial,read();
Then loop through the data parsing out the info you need, every so often you can bin whats in the buffer, as you sometimes get junk accumulating in there.
Sorry i cant help more today, but if your still stuck tomorrow, i will post up an example.