Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Raspberry Pi GPIO
Search
台灣樹莓派
PRO
October 02, 2013
Technology
0
120
Introduction to Raspberry Pi GPIO
An introduction to Raspberry Pi GPIO, including an example.
Shared in Taipei.py 2013/09/26.
台灣樹莓派
PRO
October 02, 2013
Tweet
Share
More Decks by 台灣樹莓派
See All by 台灣樹莓派
快快樂樂購買Pi 5週邊商品
piepie_tw
PRO
0
61
2024-10 到 2025-01 的 Raspberry Pi新產品介紹(Pi 5/16GB, Touch Display 2, Pi 500, Raspberry Pi Monitor, Pico 2W, USB 3 Hub, Raspberry Pi Carbon Removal Credit)
piepie_tw
PRO
0
96
2024-08 到 2024-10 的 Raspberry Pi新產品介紹(Pico 2, microSD, Bumper, AI Camera, AI HAT+)
piepie_tw
PRO
0
56
Raspberry Pi AI Kit介紹
piepie_tw
PRO
0
100
Duckiedrone - 基於 Raspberry Pi 與 Python 的小型無人機專案介紹
piepie_tw
PRO
0
980
Raspberry Pi新產品介紹(Raspberry Pi M.2 HAT+ 和 Raspberry Pi AI Kit)
piepie_tw
PRO
0
90
用Raspberry Pi玩轉Edge AI
piepie_tw
PRO
0
36
體驗 Raspberry Pi 5
piepie_tw
PRO
0
260
用Raspberry Pi + Python製作 阿里山小火車上的影音導覽系統
piepie_tw
PRO
0
1.1k
Other Decks in Technology
See All in Technology
Delta airlines Customer®️ USA Contact Numbers: Complete 2025 Support Guide
deltahelp
0
690
いつの間にか入れ替わってる!?新しいAWS Security Hubとは?
cmusudakeisuke
0
120
生まれ変わった AWS Security Hub (Preview) を紹介 #reInforce_osaka / reInforce New Security Hub
masahirokawahara
0
470
LangChain Interrupt & LangChain Ambassadors meetingレポート
os1ma
2
310
How Do I Contact HP Printer Support? [Full 2025 Guide for U.S. Businesses]
harrry1211
0
120
第4回Snowflake 金融ユーザー会 Snowflake summit recap
tamaoki
1
280
fukabori.fm 出張版: 売上高617億円と高稼働率を陰で支えた社内ツール開発のあれこれ話 / 20250704 Yoshimasa Iwase & Tomoo Morikawa
shift_evolve
PRO
2
7.6k
Connect 100+を支える技術
kanyamaguc
0
200
2025-07-06 QGIS初級ハンズオン「はじめてのQGIS」
kou_kita
0
170
20250707-AI活用の個人差を埋めるチームづくり
shnjtk
4
3.8k
Zephyr RTOSを使った開発コンペに参加した件
iotengineer22
1
220
FOSS4G 2025 KANSAI QGISで点群データをいろいろしてみた
kou_kita
0
400
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
223
9.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
4 Signs Your Business is Dying
shpigford
184
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
950
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Rails Girls Zürich Keynote
gr2m
95
14k
A designer walks into a library…
pauljervisheath
207
24k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
How GitHub (no longer) Works
holman
314
140k
GitHub's CSS Performance
jonrohan
1031
460k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Transcript
Raspberry Pi 好好玩 - GPIO 篇 台灣樹莓派 <
[email protected]
> Sep 26,
2013/ Taipei.py
• 信用卡大小般的電腦 Raspberry Pi 是什麼 ? http://www.flickr.com/photos/fotero/7697063016/
• Raspberrypi.org 基金會所設計開發 • 以低價硬體 & 自由軟體刺激電腦科學教育 • 公開的 datasheet
& 線路圖 & 原始碼 • 由 Element14/RS Components 生產製造 Raspberry Pi 是 ...
• 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)
Raspberry Pi 怎麼玩 ?
http://www.slideshare.net/raspberrypi-tw/introduction-toraspberrypi
Raspberry Pi 還可以怎麼玩 ?
Raspberry Pi 還可以怎麼玩 ? 玩他的 GPIO
• 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
• 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
Raspberry Pi 的 GPIO http://elinux.org/RPi_Low-level_peripherals SPI / I2C / UART
/ PWM
• 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
• C • Without library • wiringPi library / bcm2835
library • sysfs • Python • RPi.GPIO / RPIO package • C#, Ruby, Perl, Java, Free Pascal, Basic... Language Support
開始用 Python 控制 GPIO 吧
PIR 人體紅外線感測器 http://www.raspberrypi-spy.co.uk/2013/01/cheap-pir-sensors-and-the-raspberry-pi-part-1/
Pin Definition http://wiringpi.com/wp-content/uploads/2013/03/pins.pdf
線路圖
• Import module • Define pin numbering • Setup up
a channel • Input/Output • Cleanup Python Code
Python Code
再加點東西吧
• 小電流控制大電流 Relay 繼電器
線路圖
寫 1 個 = 寫 100 個 ?
Sensors http://www.fasttech.com/product/1257800-37-in-1-arduino-compatible-sensor-shields-mega
電子學入門
http://www.bootc.net/archives/2012/06/20/raspberry-pi-xbee-smt-backpack/
• 兩條線 , TX(Transmits) + RX(Receive) UART http://babbage.cs.qc.edu/courses/cs343/UART/
• 兩條線 , SDA(Data) + SCL(Clock) • Master/Slave I2C http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
• 四條線 , MISO, MOSI, SCLK, CS • Master/Slave SPI
http://avrhelp.mcselec.com/index.html?using_the_spi_protocol.htm
• 用數位訊號模擬類比訊號 PWM http://www.societyofrobots.com/schematics_h-bridgedes.shtml http://www.seattlerobotics.org/guide/servos.html
先別管這麼多了 你有聽過套件嗎 ?
• 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
PWM + Servo Motor http://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/overview http://pythonhosted.org/RPIO/pwm_py.html
I/O 不夠嗎 ? 那就擴充吧 !!
• PiFace Digital • Gertboard • Arduino + Raspberry Pi
• AlaMode • Arduino shields
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
Gertboard Official Add-on GPIO Expansion Board http://uk.farnell.com/jsp/search/productdetail.jsp?sku=2250034 Gertboard + Raspberry
Pi Gertboard AI Car
Arduino + Raspberry Pi http://codeandlife.com/2012/07/29/arduino-and-raspberry-pi-serial-communication/
AlaMode Arduino-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
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
自走車 機器人 http://vimeo.com/54017137
And More...
最後 ... GPIO Debugging
None
Raspberry Pi Rocks the World Thanks