Reading from Arduino by USB

Hello, I’m having an issue here, I believe you could help me.

First, in my Arduino Mega, I made a small program to read a value from a temperature sensor and send it by usb every 1 second. Using the compiler USB Monitor I get the value every second correctly. Using a VB console aplication I can do it too. But I really needed to use a VB Form aplication and get the value every second in a textbox, yet I’ve tried some solutions that occurred me but I can’t do it… always give me some error.

This is for a class in university, and begins to frustrate me because I’ve made programs much more difficult even with PICs and can’t handle this.

Thank you!

The actual code should be virtually identical to what you use for the console application. You can either setup receive interrupt handler for the Serial port, or use a Timer object to periodically fetch any received data from the serial port. A little Googling will turn up tons of examples.

Regards, Ray L.

i've tried the interrupt handler and the timer... but when I make something like:

DataReceived_SerialPort.... str=Serial.ReadExisting() textbox1.text=str

the last line makes everything crash.

kalexpt: i've tried the interrupt handler and the timer... but when I make something like:

DataReceived_SerialPort.... str=Serial.ReadExisting() textbox1.text=str

the last line makes everything crash.

That's what debuggers are for.... One thing for certain - you are doing something wrong in your code. Spending some time with Google, and seeing how other people have done it will likely solve your problem. Posting code fragments will not.

Regards, Ray L.

This seems to be a problem with VB code for your PC and not an Arduino problem.

...R