Workshops On Designing Electronic Toys #9

E6814d062e4214045659f01deb793859?s=47 Hirotaka Nakajima
June 03, 2014
93

Workshops On Designing Electronic Toys #9

E6814d062e4214045659f01deb793859?s=128

Hirotaka Nakajima

June 03, 2014
Tweet

Transcript

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

    / @nunnun http://about.me/nunnun 1
  2. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Agenda 2 • Demo (Prof. Takefuji) • Sensors

    • Schematic Editor • Serial Communication (LED3)
  3. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Demo 3

  4. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Final Project 4 • According to Syllabus:
 It

    is mandatory to present/demonstrate your masterpiece (electronic gadget) with written reports. ! • Electronic Gadget • Must have some sensor • Report • Written reports • Circuit Diagram
  5. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Sensors 5 • Kind • Temperature / Humidity

    • Gyroscope / Accelerometer • Photo sensor (LED sensor) • Pressure • Way to connect • Analog • Digital • I2C
  6. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Schematic Editor 6 • Circuit Diagram • Show

    the components and 
 connections ! ! • Fritzing
 http://fritzing.org/download/
  7. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Draw LED2 circuit diagram 7 • LED0 circuit

    diagram
 http://hirotaka.org/led0.fzz • Change diagram from led0 to led2
  8. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Serial Communication 8 • Way to communicate between

    PCs • Wireless LAN • Ethernet • Serial: Most basic / old network • Serial (RS-232C, UART) • Simple pin assign (Tx / Rx / GND) • end-to-end communication • Very slow
 (max 115,200 bps, e.g. WiFi 54Mbps = 54000kbps)
  9. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST Serial in Arduino 9 • Atmega 328p has

    UART(≒Serial) interface • RX (pin2), TX (pin3) (Check with pin mapping)
 http://arduino.cc/en/Hacking/PinMapping168 • Connect RX to TX, TX to RX • 328 TX -> AE-UW232R RxD • 328 RX -> AE-UW232R TxD • Use Serial library to setup serial connection • Serial.begin to setup the connection • Serial.println to send the data to PC
  10. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST 10

  11. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST LED3 11 • Send the data to PC

    through serial • http://web.sfc.keio.ac.jp/~takefuji/led3.tar ! • If you have done, draw diagram • AE-UM232R fritzing data
 http://www.densikit.com/home/fritzing
  12. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST 12 int ledPin=8; int sensorPin = A0; int

    sensorValue = 0; ! void setup(){ pinMode(ledPin, OUTPUT); Serial.begin(9600); } ! void loop(){ sensorValue = analogRead(sensorPin); if(sensorValue>250){ digitalWrite(ledPin, 0); } else { digitalWrite(ledPin,1); } Serial.println(sensorValue,DEC); delay(1000); }
  13. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST LED3’ 13 • LED is turned on if

    the sensor value is > 250 • It works with specific LED but not works mine (for example) • Threshold should be based on the environment • Sensor LED data several times • Determine the threshold ! • Let’s change the program!
  14. 5IFTFTMJEFTBSFDPQZSJHIU˜)JSPUBLB/BLBKJNB3FEJTUSJCVUFBOEEJTDMPTVSFPGUIFTFTMJEFTBSFOPUQFSNJUUFEXJUIPVUQFSNJTTJPOT ,FJP6OJWFSTJUZJTMJDFOTFECZJUTDPQZSJHIUIPMEFST 2VFTUJPO $PNNFOUT  IJSP!BXBTGDLFJPBDKQ IUUQBCPVUNFOVOOVO !OVOOVO 14