getting started with arduino how to build a twitter monitoring alertuino

26
Getting Started With Arduino: How to build a Twitter- monitoring Alertuino Adrian McEwen - www.mcqn.com

Upload: adrian-mcewen

Post on 13-May-2015

71.899 views

Category:

Technology


0 download

DESCRIPTION

The slides from my talk about Arduino at Barcamp Liverpool. Shows the basics about Arduino and how I hacked a toy gun to fire whenever someone mentioned #bcliverpool on twitter

TRANSCRIPT

Page 1: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Getting Started With Arduino:How to build a Twitter-monitoring

Alertuino

Adrian McEwen - www.mcqn.com

Page 2: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

What is Arduino?

Embedded computing platform Open Source Hardware Open Source Software Easy-to-use A way to build the “Internet of

Things”

Adrian McEwen - www.mcqn.com

Page 3: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Common Features

Assortment of Arduinos, but most share the same common features:

16KB flash 1KB RAM 14 digital I/O pins 6 analogue I/O pins

Adrian McEwen - www.mcqn.com

Page 4: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Easy to Learn

Integrated IDE Upload code via USB with a single

click Lots of examples to learn from Active community sharing how they

made their projects

Adrian McEwen - www.mcqn.com

Page 5: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Easy to Extend

Adrian McEwen - www.mcqn.com

Page 6: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

The Anatomy of a Sketch

The code that runs on the Arduino is called a sketch.

Two main parts:– setup()– loop()

This is the Arduino “Hello World” - Blink

Adrian McEwen - www.mcqn.com

Page 7: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

The Anatomy of a Sketch: setup()

Runs once, on startup.

Adrian McEwen - www.mcqn.com

Page 8: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

The Anatomy of a Sketch: loop()

Runs continually, after startup.

Adrian McEwen - www.mcqn.com

Page 9: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Seeing Blink in Action

1. Load Blink example in the IDE: File -> Sketchbook -> Examples -> Digital -> Blink

2. Click the upload button: 3. Watch the LED blink**on boards other than the Diecimila and Duemilanove you might

need to connect an LED between digital pin 13 and GND

Adrian McEwen - www.mcqn.com

Page 10: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Now the real fun starts…

Adrian McEwen - www.mcqn.com

Page 11: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Some (Very) Basic Electronic Concepts

You can think of electronics in a similar way to how you’d think of plumbing

Voltage [V]: a bit like water pressure Current [I]: a bit like the amount of

water flowing through something Resistance [R]: a bit like the (inverse

of the) diameter of a water pipe

Adrian McEwen - www.mcqn.com

Page 12: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Ohm’s Law

The only equation you’ll need to begin tinkering

Voltage = Current x Resistance Current = Voltage / Resistance Resistance = Voltage / CurrentLearn more as you want to do more…

Adrian McEwen - www.mcqn.com

Page 13: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Tinkering With Toys

Hacking a toy ray gun to notify me when someone twitters about #barcampliverpool

Adrian McEwen - www.mcqn.com

Page 14: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Take 1 Cheap Toy Ray Gun

Battery-operated electronic toys are ideal

Takes 3 AAA batteries, so near enough to the Arduino’s 5V

Adrian McEwen - www.mcqn.com

Page 15: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Open It Up

Find the connections to bypass the switch and turn the toy on

Use 5V and GND connections on Arduino with some wires to test where the connections should go

Adrian McEwen - www.mcqn.com

Page 16: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Make New Connections

Solder the connections ideally

But you could cut the wires and connect new ones with connecting block

Adrian McEwen - www.mcqn.com

Page 17: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Parts We’ll Use

Resistor – 1K ohm (brown-black-red)

Adrian McEwen - www.mcqn.com

Page 18: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Parts We’ll Use

Transistor – basically an electronically operated switch(we’re using a 2N2222)

Adrian McEwen - www.mcqn.com

Page 19: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Parts We’ll Use

Adrian McEwen - www.mcqn.com

Breadboard – easy, solderless prototyping board

Page 20: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Transistors in (a Bit) More Detail

Adrian McEwen - www.mcqn.com

Wire emitter to –ve/GND side of circuit Wire collector to +ve side of circuit Current will flow from collector to emitter

when a voltage is applied to base

Page 21: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Our Circuit

Adrian McEwen - www.mcqn.com

Page 22: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Software

Computer will fetch the data from Twitter for us

Then send the number of alerts over serial to the Arduino

The Arduino will listen for the number of alerts over serial

Then turn on the toy for 2 seconds for each alert

Adrian McEwen - www.mcqn.com

Page 23: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Alertuino Software: setup()

Runs once, on startup.

Adrian McEwen - www.mcqn.com

Page 24: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Alertuino Software: loop()

Adrian McEwen - www.mcqn.com

Page 25: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Lets Try It

1. Upload the Alertuino sketch2. Start the serial monitor 3. Send it a command4. Enjoy**fingers crossed ;-)

Adrian McEwen - www.mcqn.com

Page 26: Getting Started With Arduino   How To Build A Twitter Monitoring Alertuino

Find out more

My Blog: http://www.mcqn.net/mcfilter/

Or email [email protected] a beginners kit:

http://tinker.it/ukstore/product_info.php?cPath=29&products_id=51

Download the software: http://www.arduino.cc/

Learn more: http://arduino.cc/en/Tutorial/HomePage

Adrian McEwen - www.mcqn.com