Let's Make Robots!

C# To Arduino Programming

Good morning LMRian's.

I have purchased my very first Arduino (Uno), and am trying to find a simple "blink" tutorial to use C# (Visual Studio 2012) to the Arduino onboard LED.

Can anyone please recommend any links?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

So after 2 days of working with the helpful comments here, and searching the rest of the net; I came up with some code. I was having an issue with the location of the setting of the serialPort1 commands to get the light to work.

I asked on StackOverflow (fantastic community of coders), and here is a link to the code that worked for me.

This will be just the start of my coding journey into C# and Arduino, and might post how I go in a blog here? Would that be useful does anyone think? I found getting my Arduino and thinking about how to interface the code a bit daunting at the start, but like all good challenges, once one task is mastered - it's onto the next until one becomes an "expert" I guess.

Are you on about actually programming the arduino in C# (not possible) or having a C# application communicate with an arduino already programmed with some sort of sketch allowing it to be controlled in this way?

I dont play much with arduino, but i guess it has a serial port, in which case the c# is quite simple. Something along the lines of SerialPort serial = new SerialPort("COM3",115200); serial.Open(); serial.WriteLine("A"); The arduino then needs Code that recieves from the serial port, and flahses the led when an 'A' arrives. On the ipad just now so cant test any code.

That works! Thanks for that!

To accomplish that you will need two programs: the C# program on the PC, and an Arduino (C / C++) sketch on the Arduino.  They would have to communicate between the two.

I think you're going to need the Arduino IDE to use the board no matter what, in which case "Blink" is under Examples>01.Basics.  I don't know if you can subsequently use Firmata or something similar to drive the board out of the VS IDE without the intermediate step.

 

Something that won't help the OP as much, but visual studio can function as an arduino IDE too with the visual micro plugin. I had no end of problems with the standard IDE on my desktop PC so use it on there. It is literally a plugin that allows visual studio to handle arduino sketches (which it just syntax highlights as being C/C++) and the debug option then piggybacks off of the compilers and libraries in an existing arduino IDE install. Works brilliantly.

I can get C# Visual Studio 2012 Express to contact the Arduino with the post above; but that is all. I guess from the other replies that an IDE plugin is needed from the other replies and yours.

Apparently Visual Micro does work with Visual Studio Express (and that is the only free version). Does anyone have any others that they can recommend please?

Can you be clearer about what you need to do, as there is confusion. Are you trying to talk to the arduino from c#, for example using c# to write a program for use on windows or linux that allows you to control something attached to the arduino? Or are you trying to use c# to write code that will run on the arduino directly? Thanks

What I have is Windows 7 running Microsoft Visual Studio Express 2012, and have bought an Arduino Uno.

I have installed the Arduino software and successfully done the "blink" example to the board. What I would like to do is create a C# program to do the same "blink" of the onboard LED.

I have used TheGangsta's reply to successfully communicate with the board through the C# program, but don't know how to go about from here to get the "blink" example to work.

Has that cleared it up at all?