Lifelong Learning Knowledge should be uncompromisingly sought after and freely given away.

9Aug/090

Communicating With Ardunio Using Micrsoft .NET (C#)

Being a .Net developer, I figured I needed to know how to get my applications to talk to the Ardunio board via the USB serial port. Took a few hours to get the Ardunio code working, but here is the final results.

I setup a simple VS2008 C# project (you'll need to modify to compile with VS2005) to turn a LED on and off by clicking a button on the form. You'll need to change the hard-coded COM port to the correct one for your setup and hook up the LED (don't forget your resistor) to the digial PIN 12 on the Ardunio board.

  •  A few things to note: 
    • I'm using a fixed char command "INLENGTH" which will need to be updated if you wish to increase the command char length.
    • I've used # to pad the command when I don't have a 6 char command.
    • LED must be on digital PIN 12 (you can change this in the code of course).
    • COM port is hard-coded in the .Net code for my setup, change to correct COM port on our computer.

 

ArduinoSerialCommTest
Title: ArduinoSerialCommTest (460 clicks)
Caption:
Filename: arduinoserialcommtest.zip
Size: 43 KB

ArduinoSerialCommTest
Title: ArduinoSerialCommTest (460 clicks)
Caption:
Filename: arduinoserialcommtest.zip
Size: 43 KB

Tagged as: Leave a comment