Workshops On Designing Electronic Toys #11

E6814d062e4214045659f01deb793859?s=47 Hirotaka Nakajima
June 17, 2014
110

Workshops On Designing Electronic Toys #11

E6814d062e4214045659f01deb793859?s=128

Hirotaka Nakajima

June 17, 2014
Tweet

Transcript

  1. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZMPHPJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Workshops On Designing Electronic Toys #11 Hirotaka Nakajima

    / @nunnun http://about.me/nunnun 1
  2. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Agenda 2 • Using I2C Sensor • Work

    time
  3. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Sensors 3 • Kind • Temperature / Humidity

    • Gyroscope / Accelerometer • Photo sensor (LED sensor) • Pressure • Way to connect • Analog • Digital • I2C
  4. 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
  5. 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
  6. 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
  7. 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)
  8. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST I2C with Arduino 8 • http://web.sfc.keio.ac.jp/~takefuji/gy80.tar • pin

    • Arduino: A4 (SDA), A5 (SCL) • GY-80: SCL, SDA
  9. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST 9

  10. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST 2VFTUJPO $PNNFOUT  IJSP!BXBTGDLFJPBDKQ IUUQBCPVUNFOVOOVO !OVOOVO 10