Arduino08 1206641278880936 5
Arduino08 1206641278880936 5
Arduino08 1206641278880936 5
Arduino
CS4062 - Eoin Brazil - Semester 2 - 2009
http://www.flickr.com/photos/collinmel/2317520331/
What is Arduino?
The development
The hardware
The community
environment
Why Arduino?
artists & designers
opportunistic prototyping
device hacking & reuse
open source
free to inspect & modify
community
wiki, forums, tutorials
Ruby
Python
PHP
Matlab
Squeak (Smalltalk)
Examples of Arduino
Examples of Arduino
Examples of Arduino
Examples of Arduino
Examples of Arduino
Arduino Capabilities
=
Intel 286
Arduino
Arduino Capabilities
16 kBytes of Flash program memory
1 kByte of RAM
16 MHz (Apple II: 1 MHz / Intel 286: 12.5 MHz /
Intel Core 2: 3 GHz)
inputs and outputs
13 digital input/output pins
5 analog input pins
6 analog output pins (PWM only)
Layout of an Arduino
Arduino Glossary
``sketch - program that runs on the board
``pin - input or output connected to something, e.g.
output to an LED, input from switch
Arduino IO
Arduino IO
Bluetooth - BlueSmirf
Internet - MatchPort
Many others:
Wifi, IrDa, Zigbee, etc.
Arduino IO
Motors:
DC, Steppers, Servos
Arduino IO
Sensors:
Flex, IrDa, Switches,
FSR, Accelerometers
Arduino IO
Custom Hardware:
e.g. VMusic 2 MP3 player
Blinking a LED
Diagrams
Wiring
diagram
Schematic
diagram
Wired circuit
Solderless
Breadboard
+
+
1
10
15
20
25
A
B
C
D
E
A
B
C
D
E
F
G
H
I
J
F
G
H
I
J
10
15
20
25
Track
(all connected)
Drilled or cut holes
(breaks connection)
Stripboard /
Perfboard
Example
Tips:
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Project:
Designed by:
Version:
Date:
Notes:
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
22
22
21
2l1
20
20
19
19
18
18
17
17
16
16
15
15
14
14
13
13
12
12
11
11
10
10
1
1
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
stripboard diagramming
Resistor
Not direction
sensitive
LED
short leg is negative &
goes to the ground
Expensive but
user friendly
Expensive but
user friendly
Sufficient for
almost all needs
Expensive but
user friendly
Sufficient for
almost all needs
Chips and
PCBs
Arduino
ATMega168
Arduino
Approx.
~250
ATMega168
Arduino
Approx.
~250
ATMega168
Approx.
~25
Arduino
Approx.
~250
Approx.
~25
ATMega168
Approx.
~4
Programming
Programming an
Arduino
Write program
Compile (check
for errors)
Reset board
Upload to board
An Arduino Sketch
Declare variables at top
Initialize
setup() run once at beginning, set pins
Running
loop() run repeatedly, after setup()
An Arduino Sketch
int ledPin = 13; led
connected to control pin 13
Global Variables
An Arduino Sketch
pinMode() set a pin as input
or output
setup()
An Arduino Sketch
pinMode(ledPin, Output);
set the pin `ledPin' as an output
setup()
serial.Begin(9600); talk to
the computer at 9600 baud rate
An Arduino Sketch
loop()
Input / Output
Digital ? Analog ?
Digital only has two values: on/off
Analog has many (infinite) values
Computers dont really do analog - use
quantization instead
Digital ? Analog ?
Many states (Analog) or just
two (HIGH/LOW - Digital)
Number of states (or bins) is
resolution
Common computer resolutions:
8-bit = 256 states
16-bit = 65,536 states
32-bit = 4,294,967,296 states
IO to/from what?
Sensors
LDR / IR
Switch /
Potentiometer /
Joystick / Piezo
Accelerometer
Ultrasonic
Indicators
LED / Lamps
Buzzers
Actuators
Solenoid
Stepper Motor
Other Circuits
Prototype shields
Special ICs
What is a switch?
Hello World!
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
Serial.print("Hello World!\n\r");
// wait 2sec for next reading:
delay(2000);
}
/* Blinking LED --* turns on and off a light emitting diode(LED) connected to a digital
* pin, based on data coming over serial
*/
/* Blinking LED --* turns on and off a light emitting diode(LED) connected to a digital
* pin, based on data coming over serial
*/
Initialise
some of the
variables
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(19200); // initiate serial communication
}
void loop()
{
while (Serial.available()>0) {
inByte = Serial.read();
}
if (inByte>0) {
digitalWrite(ledPin, HIGH); // sets the LED on
} else {
digitalWrite(ledPin, LOW); // sets the LED off
}
}
/* Blinking LED --* turns on and off a light emitting diode(LED) connected to a digital
* pin, based on data coming over serial
*/
/* Blinking LED --* turns on and off a light emitting diode(LED) connected to a digital
* pin, based on data coming over serial
*/
} else {
digitalWrite(ledPin, LOW); // sets the LED off
}
/* Digital reading, turns on and off a light emitting diode (LED) connected to digital
* pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of
* Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.
*/
/* Digital reading, turns on and off a light emitting diode (LED) connected to digital
* pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of
* Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.
*/
Initialise
some of the
variables
void setup() {
pinMode(ledPin, OUTPUT); // set LED as output
pinMode(inPin, INPUT); // set pushbutton as input
Serial.begin(19200); // start serial communication to computer
}
void loop() {
buttonval = digitalRead(inPin); // read the pin and get the button's state
if (buttonval == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
Serial.write('0'); // Button off (0) sent to computer
} else {
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.write('1'); // Button on (1) sent to computer
}
}
/* Digital reading, turns on and off a light emitting diode (LED) connected to digital
* pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of
* Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.
*/
void loop() {
buttonval = digitalRead(inPin); // read the pin and get the button's state
if (buttonval == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
Serial.write('0'); // Button off (0) sent to computer
} else {
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.write('1'); // Button on (1) sent to computer
}
}
/* Digital reading, turns on and off a light emitting diode (LED) connected to digital
* pin 13, when pressing a pushbutton attached to pin 7. It illustrates the concept of
* Active-Low, which consists in connecting buttons using a 1K to 10K pull-up resistor.
*/
To / From
Other
Software
Pure Data
Pduino
SimpleMessageSystem
Flash
Serial Proxy
(XMLSocket server) a
small program that runs
on your Mac/PC and
keeps a live connection
between the serial port
and Flash
#define inPin 2
void setup(){
Serial.begin(9600);
}
void loop(){
byte readValue=digitalRead(inPin);
if(readValue == HIGH){
Serial.print("high");
Serial.print(0, BYTE);
}
}
Flash Example
http://file-error.net/1o1o1o1o1/?Physical_Computing_and_Interaction:Arduino:Arduino_VS_Flash
http://protolab.pbwiki.com/Arduino2Flash
Animata
Animata
Processing
Interactive Objects /
Displays
Spooky Skull Example - Tod E. Kurt
Lilypad - Leah Buechley
Wanderlust - Hector Ouilhet
Ambient Auditory Group Presence
Display
Hanging Gardens
Lilypad
A set of stitchable controllers,
sensors and actuators enables
novices to build their own
electronic textiles.
Wanderlust
A mobile service, uses identities and
needs (in terms of time and distance)
to explore spaces as well to meet
people with similar interests.
Ad-Hoc Social Networking tool as it
provides suggestions from people and
places that can be relevant to you.
The prototype used physical tokens (reels) to represent a users different
identities. Each reel is mapped to an identity; when this reel is introduced to the ViewMaster it will play a video showing the contents and attributes of this identity.
Consists of a original View-Master (red), wooden body, Arduino board, RFID
reader & antenna
Wanderlust Prototype
Hanging Gardens:
Collaboration with Jurgen Simpson
Two Places - UL / Ormeau, Belfast
Network of Speakers and Sensors
Arduino, Ruby, Max/MSP
2 field of insects
Circadian rhythm
Walls and nodes
Hanging Gardens:
Collaboration with Jurgen Simpson
Two Places - UL / Ormeau, Belfast
Network of Speakers and Sensors
Arduino, Ruby, Max/MSP
2 field of insects
Circadian rhythm
Walls and nodes
Useful Links
Arduino - http://www.arduino.cc/
Wanderlust - http://www.thejaguarhouse.com/blog/
Arduino lectures - http://www.slideshare.net/eoinbrazil
Tod E. Kurts blog (check his Spooky Arduino projects) - http://todbot.com/
blog/category/arduino/
ITP Physical Computing - http://itp.nyu.edu/physcomp/Intro/HomePage
The Art and Craft of Toy Design - http://yg.typepad.com/makingtoys2/
Lilypad - http://www.cs.colorado.edu/~buechley/diy/diy_lilypad_arduino.html
Usman Haque and Adam Somlai-Fischer - ``Low tech sensors and actuators
for artists and architects