Embedded Systems Programming

Arduino

Introduction to Arduino

Massimo Banzi helped invent the Arduino, a tiny, easy-to-use open-source microcontroller that's inspired thousands of people around the world to make the coolest things they can imagine — from toys to satellite gear. Because, as he says, "You don't need anyone's permission to make something great." -- From his TEDTalk

The AVR architecture was conceived by two students at the Norwegian Institute of Technology (NTH), Alf-Egil Bogen and Vegard Wollan. Colombian student Hernando Barragán and Massimo Banzi, with David Mellis (then an IDII student) and David Cuartielles added atmega AVR chip to create arduino. The development system based on Processing is from MIT and Casey Reas' team. These are all created by students like you. Observe the global effort. Enough about history. Lets discuss the technical details.

Techincal Details

A single-board microcontroller and a software suite for programming it.

We will be using Arduino Uno, simplest and mostly commonly used one for simple projects. The hardware consists of a simple, open design for the controller with an Atmel AVR processor and on-board I/O support. The software consists of a standard programming language and the boot loader that runs on the board. It is a tiny embedded system that you can program to connect to external components.

The Arduiono Uno version we have has Atmel Atmega 328 RISC processor: Its word size is 32bits.Flash memory (program space) 32K, is where the Arduino sketch is stored. SRAM (static random access memory) of 2K is where the sketch creates and manipulates variables when it runs. EEPROM is memory space of 1K that programmers can use to store long-term information.

We will be using Arduino Uno, simplest and mostly commonly used one for simple projects. The hardware consists of a simple, open design for the controller with an Atmel AVR processor and on-board I/O support. The software consists of a standard programming language and the boot loader that runs on the board. It is a tiny embedded system that you can program to connect to external components.

Example1: connect a led to the output, switch to input, when a switch is pressed, the light is turned on, processor counts and turns it off after 30 seconds

Example2: Replace the switch with PIR (Passive InfraRed ) sensor that will trigger the light. .. A car dome light? An intruder alarm? Simply put: An Arduino can be connected to LEDs, dot matrix displays, buttons, switches, motors, temperature sensors, distance sensors, GPS receivers, Ethernet modules, or just about any device…it can then convert it proper form (Analog to digital and vice versa) and activate response(s)

Programming the Arduino Uno

  • You will use an Arduino IDE
  • You will write code in C
  • The step by step program can be developed in the IDE and downloaded the board through serial connector
  • Arduino IDE is a “Processing” application
  • The programs are called sketches
  • There are so many ways you can program an Arduino: from Processing-based IDE on your computer, burn it into it, transfer from another Arduino…

On to the Demo..

Here is the basic sketch we are going to use:


int led = 13;

void setup() {
  // put your setup code here, to run once:
 
  pinMode(led, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led,LOW);
  delay(1000);
}

Embedded System Development

  1. Embedded system development involves cross-platform development. Typically the code is developed using an IDE (integrated development environment) on one (operating) system and deployed on a diffeent system. For example, we developed the code for Arduino AtMel Atmega using Processing-based IDE and uploaded to the memory of the Atemga chip.
  2. For this demo, the developement system was hosted my laptop and the production system is hosted on the Arduino board
  3. Once code is deployed it persists there (on arduino board in this case) until it is updated again from a development system or otherwise.
  4. The code developed was a simple cyclic executive with two major parts: (i) setup routine that initializes variables and is executed once at the beginning of execution and (ii) a loop that conatins the main code that is executed repeatedly.
  5. We designated the pin 13 as output, connected an LED to it, and looped it through HIGH and LOW values. The LED in response was turned on and off at regular intervals (period).
  6. The LED in the demo is reprentative of any system that you may want to be triggered using signal from your embedded system (in this case an Arduino board).