Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Arduino + Node == Fun

pekim
April 02, 2012

Arduino + Node == Fun

Using an Arduino Uno board, a horn, a blue light, and a nodejs app, to provide alerts.

pekim

April 02, 2012
Tweet

Other Decks in Technology

Transcript

  1. How it came about • Emergency trip to Maplin •

    Julian in Magpie mode • Bought flashing blue light • Turned it on manually for critical bugs • Mike - “I could automate that” • Julian - “Go on then”
  2. Overview • Hardware • Arduino Uno • Blue Light, Horn

    + 12V PSU, red LED • 2 x SSR • Wires and cables • Software • Arduino programming language • Node
  3. Arduino Uno • 5V supply • 14 digital I/O pins

    • 6 analog input pins • 16 MHz 8-bit Atmel processor • USB port • Simple programming language • Lots more...
  4. Hardware Arduino Uno SSR SSR 12V PSU Blue light Horn

    LED Host USB (5V) 240V AC 240V AC
  5. Communicating with Arduino • Hardware / drivers • Arduinio is

    a USB device • USB-to-serial adapter (FTDI FT232) • Appears as a serial port (TTY / COM) to host • Software • On Arduino – Serial library • On host – anything that can use a serial port • 7 bit ASCII
  6. Programming for Arduino • Language is an implementation of Wiring

    • Resembles C - somewhat simpler though • Pretty easy to write simple programs • Probably frustrating for larger programs • Built-in libraries to access Arduino's hardware • digital and analogue I/O • timers • interrupts • serial I/O • ...
  7. Arduino code for Bug Alerter • Monitors serial port for

    “commands” • Commands – stream of characters, delimited with '~' • “LIGHT ON~”, “LIGHT OFF~” • “HORN ON~”, “HORN OFF~” • “LED ON~”, “LED OFF~” • Flashes LED fast until communication established with host • Watchdog timer for horn
  8. Node app for Bug Alerter • NPM modules • serialport

    – communication with Arduino • tedious – SQL Server database driver • express, jade, stylus – simple UI for testing • Timers • for blinking LED (every 2 seconds) • Polling database for bug count • Light on – while critical bug count > 0 • Horn sounds – when critical bug count increases