Export page to Open Document format View page as slide show


What is Arduino

  • Open-source electronics prototyping platform
    • Hardware
      • arduino boards
      • arduino Shields
      • additional hardware
        • sensors (input)
        • actuators (output)
    • Software


  • Arduino boards
    • Prebuilt or build it yourself with help of open reference design
    • Contains:
      • micro-controller
      • memory
      • pins for interaction
  • Arduino shields
    • Additional board that can be mounted on arduino board to provide additional capability
    • Official shields: ethernet, wireless (Xbee) and motor
  • Additional hardware
    • Inputs: buttons, keyboards,
    • outputs: motors, leds, screens


  • Inputs to arduino
    • Manual manipulation: Buttons, rotation sensors, bending,
    • RFID, gps
    • Environment: temperature, gas, camera, microphones, light sensors, noise sensors
  • outputs from arduino
    • to computer: usb, wireless connectivity (BT, wi-fi, xbee)
    • to environment: leds, displays, motors, speakers,


  • Software is developed for the microcontroller
    • mostly defines what output is
  • Arduino programming language
    • Simplified C/C++
    • Based on wiring (http://wiring.org.co/) open-source programming framework for micro controllers
  • Arduino program is called sketch
    • programs are stored in sketch book at Arduino IDE
  • Arduino IDE
    • Simplicity based on ideas of Processing
    • Designed to be easy for people not familiar with software developers
      • Artists are one big group using arduino
    • code editor
    • compling and uploading programs to arduino board with one click

Developing software

  • arduino → C → microcontroller
    • Arduino is simplified C and only minor changes is done on compiling to C
  • Remember Arduino has little memory
    • try to use int instead of float
    • avoid unnecessary #includes

Program structure

  • void setup()
    • setup() function is run only once when sketch starts
  • void loop()
    • loop() function runs continuosly after the initial setup
    • When program goes at the end of loop function it goes back at the start of loop
  • Arduino translation to C code and inserts arduino setup and loop inside C main()
    • Arduino build creates functions inside C main function
    • int main (void) { init();setup(); for(;;) loop; return 0;}
      • init setups the hardware
    • Developer needs to concentrate only on setup and loop

Special functions

  • constrain (a, low , high)
    • Limits the variable a values between low and high
    • int temperature = constrain (temperature, 0, 24)
  • map (a, low, high, newlow, newhigh)
    • maps the value of variable a on scale low to high to scale newlow to newhigh)
    • newlow and newhigh can be used for reverse mapping e.g. int debet = map (credit, 0, 10, 0, -10)

Controlling PINs

  • Arduino board has digital and analog pins
  • PINs can be defined as input or output PINs
    • const int outPin = 11;
    • const int inPin = 12;
    • pinmode (outPin, OUTPUT);
    • pinmode (inPin, INPUT);
  • Input pins can be read, output Pins can be written on
    • val = digitalRead(inPin);
    • digitalWrite (outPin,HIGH);
    • digital Pins returns either HIGH or LOW and can write either HIGH or Low
    • analog Pins can have variety of values.


  • Lilypad protosnap board
    • 1 x LilyPad Simple Board
    • 1 x LilyPad Button
    • 1 x LilyPad Slide Switch
    • 5 x LilyPad White LED
    • 1 x LilyPad RGB tri-color LED
    • 1 x LilyPad Light Sensor
    • 1 x LilyPad Temp Sensor
    • 1 x LilyPad Buzzer
    • 1 x LilyPad Vibe board


  • IEEE 802.15.4 standard based communications between arduino boards
    • e.g. Zigbee
  • Requires Xbee module (and xbee shield)
  • Xbee v1 modules used for simple point-to-point communication.
    • Very little or no configuration needed
  • Xbee v2 modules
    • More features and possibility for more complex networking
    • upgradable firmware
    • Mesh networking

Xbee v1 configuration

  • Connect lilypad Xbee to FTDI module and FTDI module with USB to computer
  • Use terminal program to make serial connection over usb to Xbee
  • type +++ to enter programming mode
  • Use AT commands for configuration
    • ATID<int> sets PAN network ID
    • ATMY<int> sets this devices address
    • ATDL<int> defines destination address (lowest 16 bits to be exact, DH sets the highest bits (no need in this course))
    • ATWR writes the values to non volatile memory of Xbee
    • ATRE restores the factory parameters
Last modified: 2014/02/17 23:09