Page 1
Inventing… with Software and
Electronics
Page 5
Loops &
Motors &
Amps
(Oh, Boy!)
Page 8
Empire State Building 102 Stories
Or – a pile of pennies 986,426,768 Miles High….
Page 9
Conductor (Wire) A N A L O G Y
A L E R T
Page 10
Electrons A N A L O G Y
A L E R T
Page 11
Flow Rate (Gallons/Hour)
A N A L O G Y
A L E R T
Page 12
Current (Amps)
A N A L O G Y
A L E R T
Page 13
Arduino Uno Datasheet
Page 14
Circuit Happiness A N A L O G Y
A L E R T
Dead
Stressed
Healthy
Underpowered
Asleep
Page 17
Easily Possible Shorting I/O Pins to Ground Apply Overvoltage to I/O Pins Shorting I/O Pins to Each Other Exceed Total Microcontroller Current (200mA)
Ways to Kill an Arduino
Page 19
Transistor
“the most important invention of the 20th century”
Page 20
Valve
A N A L O G Y
A L E R T
Page 22
V
I R OHMS
OLTS
AMPS
To calculate: =
Page 24
Piezo-Electric Buzzer
Page 27
Did you finish building the Shift Register Circuit?
Page 28
Data Types &
Serial Communications &
Why Buttons are more complicated than you might
think….
Page 29
Serial Communications
Page 31
Computers
a. of or pertaining to the apparent or actual performance of data-processing operations one at a time ( distinguished
from parallel).
b. of or pertaining to the transmission or processing of each part of a whole in sequence, as each bit of a byte or each byte of a
computer word ( distinguished from parallel).
Serial /seer-ee-uhl/: adj.
Page 32
Serial Port (RS-232)
Page 33
Serial Port (RS-232)
Page 34
Universal Serial Bus (USB)
Page 42
{HAS NO VALUE} {TAKES NO SPACE}
Page 43
0 (false) or !0 (true)
Page 44
characters in ASCII (8- bits)
‘a’ = 0110 0001
Page 45
characters in ASCII (8- bits) [Not very useful]
Page 47
0 - 255
-32,767 to 32767
Page 48
0 - 255
0 to 65535
Page 49
0 - 255
0 to 65535
Page 50
0 - 255
-2,147,483,647 to 2,147,483,647
Page 51
0 - 255
0 to 4,294,967,295
Page 52
0 - 255
3.4E–38 to 3.4E+38
M E E E E E E E E M M M M M M M M M M M M M M M M M M M M M M
Page 53
0 - 255
3.4E–38 to 3.4E+38
M E E E E E E E E M M M M M M M M M M M M M M M M M M M M M M
OOPS!
Page 58
MIDI
Kate Charlie Jasmine
Page 59
Sending a MIDI message from a Synthesizer
One Signal Wire!
Presenter
Presentation Notes
http://www.tigoe.com/pcomp/code/communication/midi/
Page 60
Receiving a MIDI message to a Synthesizer
One Signal Wire!
Presenter
Presentation Notes
http://www.tigoe.com/pcomp/code/communication/midi/
Page 61
“play a middle C on the tenth MIDI channel, medium volume.”
Page 62
9A 45 45
“play a middle C on the tenth MIDI channel, medium volume.”
Page 63
9A 45 45
“play a middle C on the tenth MIDI channel, medium volume.”
1001 1010 0100 0101 0100 0101
Page 64
USB Serial
Everyone (for debugging) Lexa Jameyia Kate
Page 67
int temperaturePin = 0; void setup() { Serial.begin(9600); //Serial comm. at a Baud Rate of 9600 } void loop() { float temp = getVoltage(temperaturePin); //Below is a line that compensates for an offset (see datasheet) temp = (temp - .5) * 100; Serial.println(temp); // Send data to PC delay(1000); } float getVoltage(int pin) { return (analogRead(pin) * .004882814); }
Page 68
One-Wire Communication can only go so fast before data is
lost.
Page 76
I2C Addressing is complicated; it’s possible multiple devices
share the same address
Page 77
Three Wire
A third wire is added, which is used to “select” which target is being communicated with
Page 83
Serial Peripheral Interface (SPI)
Braden Quinn Jasmine
Page 85
http://www.google.com/imgres?hl=en&biw=1366&bih=643&tbm=isch&tbnid=A7EbpBYOQVNOSM:&imgrefurl=http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&docid=Af2lO6NgwhzEuM&imgurl=http://upload.wikimedia.org/wikipedia/commons/thumb/f
/fc/SPI_three_slaves.svg/350px-SPI_three_slaves.svg.png&w=350&h=278&ei=iB31T9eIHOOQ2QW43ZzgBg&zoom=1&iact=hc&vpx=198&vpy=149&dur=13510&hovh=200&hovw=252&tx=166&ty=87&sig=115355469804607511421&page=1&tbnh=144&tbnw=181&start=0&ndsp=18&ved=1t:429,r:0,s:0
,i:73
Page 86
Master and Slave can communicate simultaneously
Page 87
Faster than I2C (no addressing)
Page 88
Fact: The delay() function isn’t very accurate (+/- 1 ms)
Page 89
But what if I want to communicate faster?
Page 90
Fact: The delayMicroseconds() function is more accurate (+/-
1 us)
Page 91
However: The delayMicroseconds() function
disables interrupts
Page 93
But what if I want to communicate faster?
Page 94
Or what if I need interrupts enabled?
Page 95
Fact: Once the communication reaches a certain speed, hardware assistance is
required
Page 96
Fact: Once the communication reaches a certain speed, hardware assistance is
required
Page 98
http://arduino.cc/en/Reference/Libraries
Page 99
http://arduino.cc/en/Reference/Libraries
Page 100
http://arduino.cc/en/Reference/Libraries
Page 101
http://arduino.cc/en/Reference/Libraries
Page 102
Why Buttons are more complicated than you might
think….
Page 103
Fact: Buttons have no voltage, only a change in resistance
Page 104
Fact: Buttons have no voltage, only a change in resistance
Infinite when Open
Page 105
Fact: Buttons have no voltage, only a change in resistance
Zero when Closed
Page 106
Fact: Arduino inputs only measures signals with
voltage
Page 107
This is what we want a button press to look like!
Max Volts (“high”)
Min Volts (“low”)
Page 108
Fact: If we measure the voltage of a button, the value
will “float”
Page 109
So how can we make the button appear like a digital
signal?
Page 110
Pull-up Resistors
Page 111
5V -HIGH 5V -HIGH
Page 112
5V -HIGH 0V –LOW
Page 116
Low-Pass Filtering
Page 117
Low-Pass Filtering (Smoothing)
Page 118
Low-Pass Filtering (Averaging)
Page 119
Low-Pass Filtering
By averaging consecutive values, the rapidly-changing values are removed, revealing the
underlying “trend”
Page 121
boolean lastButtonValue; boolean isButtonOn; void setup() { lastButtonValue = digitalRead(0); isButtonOn = false; } void loop() { boolean currentButtonValue = digitalRead(); if ( lastButtonValue == currentButtonValue ) { if ( currentButtonValue != isButtonOn ) { isButtonOn = currentButtonValue; // Button value changed! } } delay(100); // Maximum Debounce time }
Page 123
Voltage Dividers