Skip to Content
自造手冊:新工業革命實務指南
book

自造手冊:新工業革命實務指南

by Paolo Aliverti, Andrea Maietta
March 2017
Intermediate to advanced
232 pages
4h 44m
Chinese
GoTop Information, Inc.
Content preview from 自造手冊:新工業革命實務指南
GPIO
187
用到重新導向運算子(>)將這筆輸
出寫入名為
export
的檔案中:
# echo 25 > export
5. 系統會產生一個名為
gpio25
的目錄
來回應上述指令,其中包含了可讓您
操作 GPIO 埠的各種檔案。有必要的
話,您可以用這個指令來釋放這個腳
位(現在先不要這麼做):
# echo 25 > unexport
6. 讓腳位先保持這樣,用 cd 指令切換
到
gpio25
目錄中,接著用 ls 看看它
的內容:
# cd gpio25
# ls
您會在這個目錄中看到一些特殊的檔
案:
active_low
、
direction
、
edge
、
power
、
subsystem
、
uevent
與
value
。
7. 您 需要 建立 一個 名為
direction
的檔
案來將腳位設定為輸入或輸出,這類
似於 Arduino 的 pinMode 指令。請將
out 這個字寫入檔案就能將某支腳位
設為輸出。若是要設為輸入,就要改
用 in。您需要再次使用 echo 指令:
# echo out > direction
8. 在 Arduino 中, 您 使 用 digitalWrite
函 式 搭 配 HIGH 或 LOW 參 數 來
點 亮 或 熄 滅 LED; 同 樣 的 事 情 在
Raspberry Pi 上 則 是 在 名 為
value
的
檔案中寫入 1 或 0。因此,請輸入以
下指令來點亮 LED:
# echo 1 > value
關閉:
# echo 0 > value
當您玩過 LED 亮滅之後,請釋放這個腳
位並離開超級使用者模式:
# cd /sys/class/gpio
# echo 25 > unexport
# exit
$ cd
$
Python 閃不停!
很幸運地,Python 有一個可以管理所有
GPIO 腳位
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
Presto实战

Presto实战

Matt Fuller, Manfred Moser, Martin Traverso

Publisher Resources

ISBN: 9789864763238