Export page to Open Document format View page as slide show

Arduino

What is Arduino

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

Hardware

  • 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

Interaction

  • 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

  • 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.

Xbee

  • IEEE 802.15.4 standard based communications between arduino boards
    • e.g. Zigbee
  • Virtualwire library helps the creating communication over Xbee
Last modified: 2013/07/01 14:42