Arduino with c sharp ?

Can i use c sharp to tell my arduino board which leds to blink? i've been trying to get c sharp working with my arduino deicimila board but everything i've come across has been far too complicated for me to understand

I understand that the computer will just recognise the board as a serial port and for which i'll be using system.io.ports but beyond that i have no clue

can anyone help?

You'll have to upload a sketch to the Arduino that will be able to recognize the serial commands being sent to it as well. Unfortunately, I'm not very familiar with C#, so I can't help with that.

Within Visual Studio, you'll need to create a SerialPort object, assign it the relevant properties and then use it to send data to the Arduino's virtual serial port. It is pretty easy to do:

*Create a SerialPort object, you can either do this in-code or by dragging one from the Toolbox onto the form in design mode (I assume you're using visual studio).

*Assign it the correct baud rate and so on; I think that the default values will be fine apart from the baud rate - this must just match whatever rate you are specifying within the Serial.begin(xxx) statement on your Arduino. The port name must be "COMxx", where xx = the port number, same one you use for uploading sketches within the Arduino IDE. You can change these properties either within the properties box in the design view, or in-code.

*Open the serial port, when you want to use it, by using "yourSerialPortObjectName.Open()".

*Write data from the port using "yourSerialPortObjectName.Write([buffer], [start index], [buffer.length])". [buffer] is a byte or char array containing the value you want to send to the arduino. [buffer.length] is just the total number of bytes/chars you are sending. [start index] is the byte in the array you want to start from.

*Close the port after using it, with "yourSerialPortObjectName.Close()".

So: if you've set up the object and its properties in Design view, and you want to send something to your arduino, this would be how (code may contain typos or mistakes but:

byte [] writeByte = new byte[1];
writeByte[0] = 0xAA;;               //single byte of value AA

yourSerialPortObjectName.Open();  //will open the port

yourSerialPortObjectName.Write(writeByte, 0, 1);  //will write this byte to the port

yourSerialPortObjectName.Close();  //will close the port

Obviously you then need your arduino to read any data received and do the relevant job.