Programming the Arduino – Basics / Part 1

Since we post up lots of Arduino related content on the website, it only makes sense that we have some sort of tutorial series to follow. This will start from the basics to the more advanced subjects, hopefully expanding your knowledge of the Arduino.

The Requirements

  1. 1x Arduino Compatible Board (Uno, Duemilanove, Leonardo, Mega etc.)
  2. Windows Environment (We’ll be using Win 7 / 8)
  3. Knowledge of basic programming (e.g. knowing what a variable, function etc. is)

All of the program code will be compatible with all versions of the Arduino; all code will run within the Uno specification, as that is what we will be using. The tutorial series will include the use of some switches, LEDs, sensors etc. which will be mentioned in either the title of the tutorial or in the requirements section.

What Part 1 will be covering

  1. Installation and Setup of the Arduino IDE.
  2. Uploading and Running your first Arduino Sketch.
  3. Explanation of basic programming functions.

Let’s get started with Part 1.

The Arduino programming language is based on Wiring, this is an open-source programming language for microcontrollers. You can write C/C++ for the Arduino, however you only need two functions defined for the program to run – It is programmed using the Arduino IDE.

We would recommend downloading the Windows Installer, which will give you start menu short-cuts and an un-installation option if you wish to remove it at a later date.

After a short installation wizard, you’ll have Arduino short-cuts in your Start Menu and Desktop. Load up the Arduino IDE by clicking on one of these icons.

 

This is the Arduino IDE. There isn’t much help from here other that writing in the large white box. Luckily, the Arduino is packed full of example code which is tucked away under the file menu.

The first thing we would recommend you look at is the Examples > Basics and BareMinimum example.

The code in this example is exactly what it says, it’s the bare minimum that will compile and run on an Arduino, it is made up of two functions a setup() section and a loop() section, none of these take any arguments and are a requirement for running your Arduino program.

 

The setup routine is what’s called at the start of the Arduino code; it gets executed before anything else and only gets executed once (on it’s own, you could call it again if you wish) this makes it a perfect place for initialising things for the first time, hence why it’s called setup.

The loop routine lives up to it’s name; it repeats over and over in a never-ending loop. This is the main program cycle and your code should be entered here.

What does the Arduino look like?

There is a series of high-quality PDFs that a user on the Arduino forums created. These used to be available at pighixxx.com but it has been down for quite a while. We have uploaded the relevant PDF below, but we will go back to linking to the site once it is back up.

Leave a Reply

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