Go Down

Topic: c++ visual studio form application serially reading data from arduino (Read 714 times) previous topic - next topic

hassan14

hi!

iv made a c++ form application using visual studio. i want to read a string, serially printed/transmitted from my arduino mega and show the string on a text box in my form application. i have tried ReadLine() and a few other functions but I am unable to do so.

this is the arduino code:
Code: [Select]

String str;

void setup()
{
  Serial.begin(9600);
 
}

void loop()
{
  Serial.println("hello");
  delay(2000);
}


i have inserted a text box and a button on my form application. i want the hello to be saved in a string and want it to appear on the text box.
(or if therez a way to serially read characters, that can do my job too)

need help with the c++ code for the form application for this :/ any kind of help will be appreciated!

econjack

I've not experimented with this class, but see if this might help:

http://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial--A-C-Class-for-Serial-Communications.htm

PaulS

Quote
need help with the c++ code for the form application for this

But you have not shown any code for the PC side.

Frankly, C++ is a crappy way to build forms applications that deal with the serial port (or that don't, for that matter).

C# makes developing forms apps so much simpler, and reading and writing from the serial port is trivial. Check out the attached application, if you want to go the easy route.

hassan14

Thankyou econjack and PaulS for your help! i will surely try these methods

Go Up