Arduino introduction

Download the Arduino software and follow the instructions on the Arduino website on how to install the necessary drivers. Most of the Arduino boards we have are the Duemilanove model, which require the FTDI drivers to be installed.

Getting Started With Arduino from the Arduino website

Arduino Code Structure

All Arduino sketches need to have the following funtions

  • setup()
    • Runs once when the board starts or is reset
    • You use the setup() for things that you usually only need to do once (like opening the serial port, defining pin modes etc.)
  • loop()
    • Runs continuously as long as the board has power

Digital Inputs and Outputs

  • The basic Arduino board has 13 digital input/output pins.
  • Digital inputs are used to read buttons/switches and other digital signals
  • Digital outputs are used to control other electric components or devices (LEDs, motors etc.)
  • Each of those pins can be either an input or an output
  • You set the pin as INPUT or OUTPUT with the pinMode() function

Analog Output

The basic Arduino board does not have real analog output, but some of the pins support PWM (pulse-width modulation). PWM lets us to “fake” an analog signal with digital outputs. It can be used to fade lights, control the speed of motors etc.

Analog Input

The Arduino Duemilanove/UNO/Leonardo boards have 6 analog inputs. They are 10-bit ADCs (analog-to-digital converters). The analog inputs are used to read analog sensors.

Logic Level and the Resolution of Inputs and Outputs.

Function 0V 5V
digitalRead() LOW HIGH
digitalWrite() LOW HIGH
analogRead() 0 1023
analogWrite() 0 255

Serial Communication

The Arduino uses a serial port to send/receive data between the board and the computer (or any other device that supports serial communication).