What Makes Arduino Programming Different

If you already know C++ from desktop development, and want to get into making your own external embedded devices with your skills, this is the place to start.

 

There are some minor differences between programming in the Arduino and Embedded environments, when compared to standard desktop C++ development, outlined below to get you started quickly. If you know the Arduino Environment, there is a quick guide here to show you the Visual Micro IDE Elements.

Arduino 

"Sketch"

When programming using the Arduino platform, each project is structured with a folder called projectName, containing an INO file, projectName.ino.  This is the main "sketch" file for the project.

In the main sketch file, there must be two functions which must be present:

Setup()

This is run once when the board starts up, and is often used to initialize the environment, sensors, and communications devices. 

Loop()

This is run after the setup() function, and is an infinite loop.  This is where you can place the main program code to run forever, until the device restarts, and the whole process begins again.

 

Note Icon Note:

Using Visual Micro the folder structure, INO file, and mandatory functions are all created automatically when you create a new project in Visual Micro.

 

Embedded Programming

When programming any embedded device it is always useful to remember what constraints you are working within on your hardware.  As the processors and memory are limited when compared to a desktop PC, generally it is best to keep things as simple as possible, and to remember that there is only so much that can be stored in both SRAM and RAM.

Although using the C++ language, it is a reduced instruction set of the language to make it compatible with such small memory and CPU constraints.  Additional functionality can be added from C++ as needed where compatible versions are available.

 

Sensing and Driving

Being able to sense the real world, as well as drive a whole variety of output devices opens up a whole new world of exciting projects.  We often get used to everything working every time on a desktop, and as you begin to interact with sensors and outputs, you will find that the real world is far less consistent than you might expect....  This gives some new challenges to be tackled by the developer, and often find such experience invaluable when going back to other development platforms.

 

Programming the Board/Chip

This is the equivelant of deploying your compiled C++ binary to another server to run, with the server in this case being a lot slower, not running an OS in the modern sense, and with limited resources and IO devices. This also means any changes to your code mean it needs to be re-compiled and uploaded to the board again.

 

Programming

To get the compiled binary onto the target processor it has to be uploaded on to the chip using a programmer.

Most development boards come with this built in, so nothing beyond a USB lead is needed to get started. A variety of external programmers also available for when you progress to building your own custom projects without development boards.

 

Debugging

The external CPU running your compiled code can bring challenges when you want to attach a debugger to find out what the runtime application is doing.

Visual Micro has a number of Debugging options, which are best explored once you are happy programming and uploading your code, as they become invaluable as projects grow in complexity.

 

Next Steps

Now that you have a board, and know whats different, the below should get you up and running in no time...

Installallation of Visual Micro In Visual Studio

Quickstart Guide for VS Users