Hello World on the Arduino

Love it or hate it, every programmer typically wets their feet by writing a “hello world” program in their new programming environment. Since unlike with the type of code I’m used to writing the Arduino board doesn’t come with a CRT or LCD screen to output this text, we have to find a more creative way to do this. There are many options, such as LEDs, peizo buzzers, small LCD pannels and speakers that could be used to output a message. The Hello World sketchbook found in the examples outputs the text “Hello World” to the serial port monitor, we will be building upon this example and using an LED to output this same message. The Duemilanove comes with an LED build into the board and is attached to PIN 13. This is very convenient as the experimentation kit did not come with even a single LED to play with. I did, however, order a couple different types of LEDs with my order as I knew I wanted them to play around with. For this example we will use the onboard LED as it requires no wiring and gives you a good way to get comfortable with uploading your program to the board and the basic structure of the code.

Start off by loading the Arduino development environment and on the main menu select File->Examples->Stubs->HelloWorld. The following project will be loaded into your sketchbook:

void setup() {

void loop() {
  Serial.println("Hello World!");

This is the basic structure of all Ardino programs. These two functions are the heart of every program you will write, so it doesn’t hurt to take a moment and discuss them. Both functions must be declared outside of the scope of all other functions. They are declared as void so they are not expected to return any value and they do not require any parameters. The setup funciton is called once when your board first powers up, and is used to initialize any devices or pins that are going to be used in your program. After the setup function executes the loop function begins to run, and it will continue to run endlessly until you power off your board. When first beginning to work with microcontrollers it takes a bit of time to wrap your head around the way the execute code, in an infinite loop, as this is somewhat different from the way any programs would run on your desktop or server computer.

In the setup function you will see that the board is configured for serial communications with the command Serial.begin(9600);.

Tags: , , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

Leave a Reply