Saturday, December 25, 2010

Arduino and C#

In the previous article we use Serial Monitor tool to view received data and send data through serial port. Today we will write our standalone Serial Monitor like tool in C#.
We will create new Window Forms Application and add the following components from the picture
C# serial tool

The refresh button will add com ports to the combo box. Let see how it is implemented

Now when we have the name of serial port, we need to create serial port object and connect it, then send/receive data.

Be careful, do not write data directly to the output text box in read_serial_port function, because you can't access a control created in another thread. To do that you need to invoke some updater function like this

Lets write the "echo" program in Arduino and see how our tool works.

Now we will upload above code to Arduino and run the tool. And it works. hurray:)
Working serial tool
Thats all. Next time we will connect accelerometer to the Arduino and write a tool to see values of sensor on the computer.

1 comment: