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

Workshops On Designing Electronic Toys #11

Hirotaka Nakajima
June 17, 2014
120

Workshops On Designing Electronic Toys #11

Hirotaka Nakajima

June 17, 2014
Tweet

More Decks by Hirotaka Nakajima

Transcript

  1. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST I2C 4 • Inter-Integrated Circuit • Bus spec

    for internal device communication • Bus speed: 100kbps, 400kbps ~ 3.4Mbps • Shared 2 physical pins for I/O • Clock signal (SCL) • Data transfer (SDA) • 10k pull-up resistor • Master-Slave model • Binary protocol
  2. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST I2C 5 • 1. Start bit (1 bit)

    • 2. Slave Address (7 bits) • 3. Read / Write flag • 4. Acknowledgement (1 bit) from slave • 5. Data (8 bits) • 6. Data-Acknowledgement (1 bit) from slave • 7. Stop bit (1 bit) Chart: http://nora66.com/avr/prog2.html
  3. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST I2C 6 • 1. Start bit (1 bit)

    • 2. Slave Address (7 bits) • 3. Read / Write flag • 4. Acknowledgement (1 bit) from slave • 5. Data (8 bits) from slave • 6. Data-Acknowledgement (1 bit) • 7. Stop bit (1 bit) Chart: http://nora66.com/avr/prog2.html
  4. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST I2C with Arduino 7 • Arduino I2C support:

    Wire
 http://www.arduino.cc/en/Reference/Wire • Lots of libraries for sensors • Today we will use GY-80 • L3G4200D (3 axis gyro) • ADXL345 (3 axis accelerometer) • HMC5883L (compass) • BMP085 (temperature & pressure sensor)