Pre Lab 3.1: Set-Up and “Hello World”

This pre-lab will basically get you up and running using the Arduino software and uploading a sketch to the Arduino board. Once you’ve completed this step we can continue to the more exciting stuff.

What is Arduino?

Arduino is a tool for making computers that can sense and control the physical world. It’s an open-source physical computing platform based on a simple micro-controller board, and a development environment for writing software for the board.

Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be stand-alone, or they can be made to communicate with software running on a local or remote computer. Arduino is intended for use by both non-technical people with no previous programming experience and seasoned pros who love to tinker. Arduino was developed in Italy by Massimo Banzi and a group of people who believed Hardware and Software should be “Open Source” and available to everyone. You can watch this 15-minute interesting TED Talk by Massimo to know more about the Arduino philosophy and its applications:

Why Use Arduino?

Arduino simplifies the process of working with microcontrollers, while at the same time offers some advantage over other systems:

  1. They are inexpensive compared to other microcontrollers.
  2. They are platform independent i.e. supports Windows, Linux, Mac operating systems.
  3. The Arduino programming environment is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well.
  4. Open source and extensible software and hardware.


The installation instructions are for Linux. Windows users can find the instructions here .

  • Open a terminal and execute the following command to install the compiler and the libraries packages:
  • Add yourself to the group ‘dialout’ in order to have write permissions on that port:

  •  Launch the Arduino application by double clicking on the Arduino application icon from the launcher. After the lab, please skim through this link to get acquainted with the Arduino Development Environment.


“Hello World” of Arduino

Now that the development environment has been setup, we’ll write a very simple program to make sure that everything is setup and ready for the future lessons. It will verify the Arduino is working as intended. To implement this program, you’ll need the following items:

  1. An Arduino Board. Each student is provided either with a Seeeduino ADK or Mega ADK or Arduino Uno or Seeduino.
  2. An Arduino shield that should be mounted on top of the Arduino board. The shield makes it easier to connect sensors and other devices to the Arduino board.
  3. A USB cable to connect the Arduino board to the host computer. The USB cable differs from one board to another.
  4. Two different sensors.
  5. An  LED.
  6. Necessary jumper wires.

Connect the LED to the board. LEDs are directional components. That means if you put it in backwards it will not work! To help you put the LED in right, the LED factory cuts the legs at different lengths. The longer leg goes in the hole marked 13 and the shorter one goes in the hole marked GND. Now connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.


After completing the hardware setup, next step is to launch the Arduino. Open the Blink sketch (Go to the File menu -> Examples -> Basics -> Blink). Sketches are little scripts that you can send to the Arduino to tell it how to act. The window should now look like below figure, with a bunch of text in the formerly empty white space and the tab Blink above it. Don’t be afraid if you haven’t worked with the Arduino IDE before. It has a very clear and basic structure and it provides just enough functionality for you to develop properly for the Arduino platform. The code editor provides syntax highlighting but, unfortunately, no code completion, which can make developing against external libraries a little bit harder because you have to look up function definitions in the library code directly.

An Arduino sketch has two important methods. The first one is the setup method, which only runs once at the beginning of the code execution. This is the place where you would do your initializing routines. The second is the loop method. This method runs in an endless loop until the board is reset. This is the place where you would implement your program logic. As you can see in the following figure, the lifecycle of an Arduino sketch is fairly simple.

Life cycle of an Arduino program

Let’s talk about what the code does. First a constant is defined specifying which pin the LED is connected to. In the setup method that pin is initialized an output. The loop method runs endlessly until the board is reset. In the loop method, we just turn the LED on for 1 second and then turn it off for 1 second to achieve the blinking effect. Please watch this video to get a better understanding of the code.

If everything is okay, you can connect your ADK board to your computer. You need to tell the IDE to which port you connected your ADK board and which type of board it actually is so that the IDE can transmit the program code to the board in the correct way. You can select the appropriate board and serial port as shown below. Choose the same board both for Mega ADK and Seedstudio ADK. /dev/ttyACM0 is the serial port for Mega ADK, while for Seedstudio it will be /dev/ttyUSB0.

After everything is ready, we can upload the code to the Arduino board. Click on the verify button to compile the code. After compilation is complete, click on the upload button to write the code to the Arduino board. You should see the LED start blinking. If you don’t get a blinking LED, make sure you put the part in the right way, in the correct holes, and perhaps try a different LED as it may be bad.

This concludes the pre-lab, however it is strongly recommended to read this concise+comprehensive introductory tutorial. If you have time you may also try out this video series by the co-creater of Arduino project.  Arduino Playground is another good source where all the users of Arduino contribute and benefit from their collective research.