Download - Introduction to Raspberry Pi GPIO
![Page 1: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/1.jpg)
Raspberry Pi 好好玩- GPIO 篇
台灣樹莓派
Sep 26, 2013/ Taipei.py
![Page 2: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/2.jpg)
● 信用卡大小般的電腦
Raspberry Pi 是什麼 ?
http://www.flickr.com/photos/fotero/7697063016/
![Page 3: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/3.jpg)
● Raspberrypi.org 基金會所設計開發
● 以低價硬體 & 自由軟體刺激電腦科學教育
● 公開的 datasheet & 線路圖 & 原始碼
● 由 Element14/RS Components 生產製造
Raspberry Pi 是 ...
![Page 4: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/4.jpg)
● SoC Broadcom BCM2835● CPU: ARM11 family, 700 MHz● GPU: Broadcom VideoCore IV, OpenGL ES 2.0,
1080p30 H.264/MPEG-4 AVC decoder● Memory: 512 Mb SDRAM
● Video outputs: Composite, HDMI● Audio outputs: 3.5 mm jack, HDMI● Onboard storage: SD, MMC, SDIO card slot● Onboard 10/100 Ethernet RJ45
Raspberry Pi 硬體規格 (Model B)
![Page 5: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/5.jpg)
Raspberry Pi 怎麼玩 ?
![Page 6: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/6.jpg)
http://www.slideshare.net/raspberrypi-tw/introduction-toraspberrypi
![Page 7: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/7.jpg)
Raspberry Pi 還可以怎麼玩 ?
![Page 8: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/8.jpg)
Raspberry Pi 還可以怎麼玩 ?
玩他的 GPIO
![Page 9: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/9.jpg)
● A generic pin on an IC
General Purpose Input Output(GPIO)
http://raspberrypihobbyist.blogspot.tw/2012/09/so-many-inputs-so-few-gpio-pins.html
![Page 10: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/10.jpg)
● Enable or disable a GPIO pin● Set which signal level is 'active'● Determine whether it's an input or output● Write a value to a pin● Read a value to a pin● Set the edges that will generate input interrupt● Wait for an interrupt to occur
How GPIO Software Works
![Page 11: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/11.jpg)
Raspberry Pi 的 GPIO
http://elinux.org/RPi_Low-level_peripherals
SPI / I2C / UART / PWM
![Page 12: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/12.jpg)
● Kernel-level support● read, write, ioctl /dev/i2c, /dev/spidev, /dev/mem
● Application-level support● sysfs → read, write /sys
● Script-level support● C extension with /dev/mem + import module
Linux Software Support
![Page 13: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/13.jpg)
● C● Without library● wiringPi library / bcm2835 library● sysfs
● Python● RPi.GPIO / RPIO package
● C#, Ruby, Perl, Java, Free Pascal, Basic...
Language Support
![Page 14: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/14.jpg)
開始用 Python 控制 GPIO 吧
![Page 15: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/15.jpg)
PIR 人體紅外線感測器
http://www.raspberrypi-spy.co.uk/2013/01/cheap-pir-sensors-and-the-raspberry-pi-part-1/
![Page 16: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/16.jpg)
Pin Definition
http://wiringpi.com/wp-content/uploads/2013/03/pins.pdf
![Page 17: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/17.jpg)
線路圖
![Page 18: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/18.jpg)
● Import module ● Define pin numbering● Setup up a channel● Input/Output● Cleanup
Python Code
![Page 19: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/19.jpg)
Python Code
![Page 20: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/20.jpg)
再加點東西吧
![Page 21: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/21.jpg)
● 小電流控制大電流
Relay 繼電器
![Page 22: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/22.jpg)
線路圖
![Page 23: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/23.jpg)
寫 1 個 = 寫 100 個 ?
![Page 24: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/24.jpg)
Sensors
http://www.fasttech.com/product/1257800-37-in-1-arduino-compatible-sensor-shields-mega
![Page 25: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/25.jpg)
電子學入門
![Page 26: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/26.jpg)
http://www.bootc.net/archives/2012/06/20/raspberry-pi-xbee-smt-backpack/
![Page 27: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/27.jpg)
● 兩條線 , TX(Transmits) + RX(Receive)
UART
http://babbage.cs.qc.edu/courses/cs343/UART/
![Page 28: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/28.jpg)
● 兩條線 , SDA(Data) + SCL(Clock)● Master/Slave
I2C
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
![Page 29: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/29.jpg)
● 四條線 , MISO, MOSI, SCLK, CS● Master/Slave
SPI
http://avrhelp.mcselec.com/index.html?using_the_spi_protocol.htm
![Page 30: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/30.jpg)
● 用數位訊號模擬類比訊號
PWM
http://www.societyofrobots.com/schematics_h-bridgedes.shtmlhttp://www.seattlerobotics.org/guide/servos.html
![Page 31: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/31.jpg)
先別管這麼多了
你有聽過套件嗎 ?
![Page 32: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/32.jpg)
● RPi.GPIO
● $ sudo apt-get install python-rpi.gpio● $ curl RPi.GPIO.tar.gz| tar zxvf && sudo python setup.py install
● UART
● $ sudo apt-get install python-pip && sudo pip install pySerial● PWM
● $ git clone https://github.com/metachris/RPIO.git● I2C
● $ git clone https://bitbucket.org/thinkbowl/i2clibraries.git● SPI
● $ git clone https://github.com/lthiery/SPI-Py● $ sudo apt-get install python-smbus
Python Packages
![Page 33: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/33.jpg)
PWM + Servo Motor
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/overview
http://pythonhosted.org/RPIO/pwm_py.html
![Page 34: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/34.jpg)
I/O 不夠嗎 ?
那就擴充吧 !!
![Page 35: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/35.jpg)
● PiFace Digital● Gertboard● Arduino + Raspberry Pi● AlaMode● Arduino shields
![Page 36: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/36.jpg)
PiFace Digital Official I/O Expansion Board
=+
http://uk.farnell.com/piface/piface-digital/board-i-o-expansion-raspberry-pi/dp/2218566
PiFace
Raspberry Pi PiFace + Raspberry Pi
![Page 37: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/37.jpg)
GertboardOfficial Add-on GPIO Expansion Board
http://uk.farnell.com/jsp/search/productdetail.jsp?sku=2250034
Gertboard + Raspberry Pi
Gertboard AI Car
![Page 38: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/38.jpg)
Arduino + Raspberry Pi
http://codeandlife.com/2012/07/29/arduino-and-raspberry-pi-serial-communication/
![Page 39: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/39.jpg)
AlaModeArduino-Compatible Shield for Raspberry Pi
http://www.makershed.com/AlaMode_for_Raspberry_Pi_p/mkwy1.htm
AlaMode
AlaMode + Raspberry Pi
AlaMode + Raspberry Pi + Arduino Wireless Shield
![Page 40: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/40.jpg)
Arduino Shields
http://www.cooking-hacks.com/index.php/documentation/tutorials/raspberry-pi-to-arduino-shields-connection-bridge
Raspberry Pi to Arduino shield
Bluetooth PRO shield for Raspberry Pi
RFID Shield for Raspberry Pi
GPRS/GSM Shield for Raspberry Pi
Raspberry Pi
![Page 41: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/41.jpg)
自走車 機器人
http://vimeo.com/54017137
![Page 42: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/42.jpg)
And More...
![Page 43: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/43.jpg)
最後 ...
GPIO Debugging
![Page 44: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/44.jpg)
![Page 45: Introduction to Raspberry Pi GPIO](https://reader034.vdocuments.site/reader034/viewer/2022052303/5552dcd5b4c905014c8b4b14/html5/thumbnails/45.jpg)
Raspberry Pi Rocks the World
Thanks