I2c
I2c
TX RX clock
data A->B
Device A Device B Device A Device B
data B->A
RX TX
Each device must have good “rhythm” Neither needs good rhythm, but one is the conductor
Is one better than the other? It depends on your application. Async is good if there are only two
devices and they’re both pre-configured to agree on the speed (like your Arduino sketches)
Synchronous is generally better for faster speeds (because you don’t need an accurate clock, just
the ability to watch the clock wire).
I2C, aka “Two-wire”
Synchronous serial bus with shared a data line
a little network for your gadgets
SCK clock
Master
device
SDA data
non-volatile
memory
touch sensor compass
fm transmitter
Does all the hard PWM & waveform generation for you
You should be able to buy these from Sparkfun.com in a month or so.
Nintendo Wii Nunchuck
• Standard I2C interface
• 2 buttons
• $20
If you look at the architecture for the Nintendo Wii and its peripherals, you see an almost un-Nintendo adherence
to standards. The Wii controllers are the most obvioius examples of this. The Wii controller bus is standard I2C.
The Wii remote speaks Bluetooth HID to the Wii (or your Mac or PC)
Because it uses standard I2C, it’s easy to make the Nunchuck work with Arduino, Basic Stamp or most other
microcontrollers.
See: http://www.wiili.org/index.php/Wiimote/Extension_Controllers/Nunchuk
and: http://www.windmeadow.com/node/42
and: http://todbot.com/blog/2007/10/25/boarduino-wii-nunchuck-servo/
And then there’s the Wii Remote, besides Bluetooth HID, it also has accelerometers, buttons, speaker, memory, and
is I2C master.
Accelerometer?
• Measures acceleration
(changes in speed)
• Gravity is acceleration
SCK
Arduino “Wire” library
Writing Data
Load Wire library
Join I2C bus
(as master)
Start sending
Send data
Stop sending
And what the various commands do are documented in the instructions / datasheet for a particular
device.
Arduino “Wire” library
Reading Data
Get data
And what the various commands do are documented in the instructions / datasheet for a particular
device.
Wiring up the Nunchuck
We could hack off the connector
and use the wires directly
n/c +V SCK
+V SDA
Note there *are* labels on the adapter, but they’re wrong. So you’ll have to trust the diagrams
above
Wiring it Up
SCK (pin5)
SDA (pin 4)
+5V SCK
GND SDA
Pluggin’ in the ‘chuck
Trying the Nunchuck
“NunchuckPrint”
You’re a cyborg!
switches/buttons
resistive sensors
LEDs Z
X
piezos
serial
pulse width communication
modulation I2C
analog I/O
http://todbot.com/blog/bionicarduino/
Tod E. Kurt
tod@todbot.com