Have you ever wanted to control some LEDs with your Arduino from a program you have written? Well I'm here to help you with just that. This is my First 'able so please help me out if i mess up along the way. And feel free to add on and change any of the code to fit your needs.

Step 1: Open a new project

Open up Microsoft Visual Studio 2010 or Microsoft Visual C# 2010 and make a open a new C# Project and name it what ever you want. I will call mine "Arduino Led Controller". After you name it, click okay.
<p>worked like a charm. I used it to controll a servo based on date in a sql database. THANKS! </p>
<p>I have tried this code for com3 on my pc but it says access denied kindly help me</p>
Which ARDUINO model do we need for this tutorial? Can you please share the product link.<br>Thank you
The arduino I used in this instructable is the Duemilinove however i would assume you could use any board just edit the code accordingly.
Hello!, nice tutorial, what changes are necessary in the VB code to control leds with keyboard instead of buttons?
<p>We can Do this but not through VB...This can be done using a Processing sketch.</p><p>I press 1,2,34, keys on the keyboard and accordingly led's turn on......</p><p>I can make an instructable on this if you want. </p>
I don't entirely understand what you mean? Could you elaborate please and maybe I could help you out
<p>Hi , i try this code.... in my PC my arduino was in COM11... but when i use that port in C# program then the program failed. it was showing &quot;Access is denied&quot; . how can i access COM11 in C# program</p>
<p>You mustn't to access COM11 in C# program. If you have linux, you can unlock that port from one command (for Ubuntu): </p><p>sudo chmod a+rw /dev/COM11</p>
<p>did you solved the connection lost problem if your arduino disconect the program will crash imidietli </p>
<p>Hi the seaker. Awesome thread. I'm a complete noob with Arduino and Visual Studio but your 'how-to' has helped me understand how the two communicate.</p><p>One problem though... I am receiving this error message....</p><p>&quot;An unhandled exception of type 'System.UnauthorizedAccessException' occurred in System.dll</p><p>Additional information: Access to the port 'COM4' is denied.&quot;</p><p>Now COM4 is definitely where my Arduino is plugged in, could there be something up with the code? Looks as though the port is opened already?</p><p>You probably wont read this but if anybody else has encountered this problem and overcome it, I would be very grateful to know how.</p><p>Thanks guys!</p><p>Frankie</p>
<p>Hey dude nic work....i have a small problem...im using arduino mega...i wnt to control 40 LEDs.plz can put me the C# code please...thnx :)</p>
Hello the seaker, I want to control 4 LED but I want to use my laptop keyboard. <br>I need to create a C# program but I dont Know how to write the VB code so that the program communicates with arduino each time I press some key (A,S,D,F, or direction keys), each key turns on a different LED. <br>Thanks for the help.
Hmm I don't know exactly how to do it but I have a few ideas. You can use a textbox that waits for updates,when a letter is typed in have it send a serial signal to the arduino that the arduino will process and then turn the led on or off depending on the state. It shouldn't be that heard I think, but I'm sure we can find you some more detailed help somewhere here.
Thank you the seaker, I am still browsing on the internet to find out a way to do that.
nice instruct,<br>Im new into the microconrollers but have mess with programming in vb6, asp3.0, js ect and last year got into c#. this is perfect for many things, I plan to adopt it to change eeprom values from the c# prog. Maybe to store a patterns/modes for some leds or the likes.<br>But untill my shift reg's get here i may just make a simple prog like you have.<br><br><br>regards.<br>
Thanks for the feed back! And if you come up with a updated program let me know, id love to see what you can come up with!
How do you show the serial feedback in visual studio?
Use the Serial Monitor in Arduino. <br> <br>I only wish it did hex.
im sorry, but that means..?
I think that this program is break<br>
yay, go Seaker!!! sorry, just here to show some support for my bestie..hope that's okay...from the very little that i know, it looks good!!! :)
haha its good to &quot;see&quot; a frendly face showing some support:) thanks bestie! i never new you had an account here!! instructables is my favorite website ever!
i just made it!! i finally remembered to click the link you sent me, and i wanted to show some support so i made an account!!! keep up the good work bestie!!!!
If you could modify this to work with java that would be so awesome. In fact, let me know if you ever do something like that. Their is a lot of potential in somthing like this, now you just need to think of something good to do with it. good ible!
thank you. i will definitely look into using java, i didn't even think of that. Thanks for the idea!!! and this is my first ible so i will be sure to review and post updates!

About This Instructable




Bio: I am a young adult looking to increase my electronic knowledge as well as my skills. i have built a photoelectric digital lap counter and ... More »
More by the seaker:Controll Leds With an Arduino From a C# Program 
Add instructable to: