Tutorial: C# Communicating with Arduino over Serial

11

Category : Arduino, Electronics, Windows

In this tutorial I’ll try to show you how to easily tell an arduino what to do from a C# program using serial communication. The only thing the C# program does is send a byte to the arduino, and the arduino program will then set pin 13 to HIGH or LOW.

Lets start with the C# sourcecode, it’s written in C# Express 2010 which you can download for free here. Get the C# project files:

Download CSharpEasySerialSource.zip

I tried to comment the code so that it should explain most of the stuff going on. But it’s pretty basic, you select the current comport then hit Connect. If you selected the correct port that the arduino is using it should now be connected. The textbox only takes numbers, writing text there will only result in it being converted to bytes.

When you click Send it will try to send the contents of the textbox to the arduino. In my example code I used “0” and “1” for turning off an on the LED. Lets look at the Ardunio example:

What the program does it’s listening on the serial port. And when it receives a “1” pin 13 goes HIGH, and if it receives “0” it goes LOW. Pin 13 is in most cases a LED thats on the arduino board, so you only need a bare arduino to test it. And if you don’t know any C# and just want to use the program to control a arduino I’ve created a zip file containing only the .exe file for the program:

Download CSharpEasySerial.zip

New stuff arrvied! :D

2

Category : Arduino, Electronics

Yupp, just a short little update.

I got the RF sender & receiver from Sparkfun today!

RF Link 2400bps Receiver – 315MHz
RF Link Transmitter – 315MHz

Also a 20×4 serial LCD, gonna be useful for advanced applications. Anyhow, if you got the RF kit, and was like me wondering how to get it working. I found this nice guide at LMR.

Now it’s just to find a nice way to use the RF links, it’s only one-way communication, but it’s gonna be awesome to use it as a remote for one of my robots!

My new Serial LCD arrived!

3

Category : Arduino, Electronics

Got my Serial 16×2 LCD today, I’m still quite noob when it comes to serial. But I’m gonna put out some simple and easy to follow tutorials for stuff when I get the hang of it 🙂

Anyhow, here’s just a little youtube clip showing some of my projects today!

[youtube=http://www.youtube.com/watch?v=Sc4B0LAatDo;ap=%2526fmt%3D18&w=425&h=344]

[youtube=http://www.youtube.com/watch?v=DwIn_AbCuVw;ap=%2526fmt%3D18&w=425&h=344]