Getting Started with Arduino, as a .NET Developer

Some time ago I got into Arduino, the open source electronics prototyping platform. I know as a .NET developer I was expected to go instead for the Netduino variant but I’ll explain in a future post why I choose for Arduino instead. As an Arduino developer, typically you use the Arduino IDE to write your code (it’s called a sketch) and upload it to your board. But as a .NET developer you can use your familiar Visual Studio environment instead! In this post I’ll write down all the steps I took to get a jumpstart into Arduino development as a .NET developer.

Buy some Arduino hardware

arduino_transparentYour first Arduino board should be the Arduino UNO, it has an integrated USB port so you won’t have any issues programming it. Later on you can move to more advanced boards but trust me, as a beginner this is a good choice. Optionally you can buy the Ethernet Shield which will add network connectivity to your board (highly recommended). The UNO costs around €20, and the Ethernet Shield around €40. If you live in Belgium like me, I can recommend iPrototype and Floris.cc to buy them online (there are many more shops which are selling them, make sure you get a genuine one). Don’t forget you need to get a A/B USB cable in case you don’t have one lying around.

Install the Arduino software

Even if you plan to use Visual Studio to write code, you still need to install the Arduino IDE, download it here.

Run your first sketch

arduinoideStart the Arduino IDE, go to the File menu, and choose the Blink sketch in Examples/Basics. This will load some code which will make the Arduino blink a LED. Exciting isn’t it! 🙂 In the sample code you’ll find the setup method which will be called once, and the loop method which will be called once setup is done (and it will be called again and again and again …). The UNO board has a LED attached to pin number 13, so the codes will blink the LED every second (1000ms). To test the code, plug in your the USB cable, and click Upload (in the toolbar or on the File menu). It could be you need to select the right port in the Tools/Serial Port menu if the upload doesn’t succeed.

Once your code is uploaded, your UNO board will boot and you’ll see your light blinking. Congratulations you have successfully upload your very first Arduino sketch!

Install the Arduino IDE for Visual Studio (by Visual Micro)

Go to http://www.visualmicro.com/ and download the Arduino IDE for Visual Studio (you’ll be redirected to the latest version hosted on CodePlex).

Write your first sketch in Visual Studio

Open up Visual Studio and choose File, New Sketch Project (and give your project a name). You can copy and paste the Blink sketch code into Visual Studio to give it a try. Notice you have Intellisense, code completion, integration with Source Control … for your Arduino code, pretty cool!

arduinoinvs

When you are ready to upload, just hit F5 and see the magic happen. Behind the scenes Visual Studio will still make use of the original Arduino software so everything you do in Visual Studio will be 100% compatible (and visa versa).

There you go, you are now ready to conquer the Arduino world!

Leave a Reply

Your email address will not be published. Required fields are marked *