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 自造手冊:新工業革命實務指南
第 16 章 Arduino
162
這些腳位可以調整輸出訊號的頻率;以
水龍頭來比喻的話,意即除了完全開啟
/關閉以外,您還可以決定水流的大小。
這對某些裝置來說非常有用,例如調整
馬達的轉速,或者是 LED 燈的亮度。但
它的運作原理是什麼呢?
基本上,它的原理與傳統的每秒 24 格電
影放映機相同:
• 若只投影黑格,成像為黑色。
• 若只投影白格,成像為白色。
• 若交錯投影黑格與白格,成像就是灰
色。若您加上比例,例如兩個黑格、
一個白格,則成像 為 深黑色;相反
地,兩個黑格、一個白格,成像即淺
灰色。
Arduino 不只有 24 個,而 是高達 256 個
「灰階」,也就是說,當數值是 128 的時
候,輸出會剛好在中間。在腳位 9 輸出
128 的指令如下:
analogWrite(9, 128);
第一個參數代表所使用的腳位,第二個
參數是所應用的類比數值。analogWrite
(9 , 0) 等於 digi t alWr i te (9 , LOW),而
analogWrite (9,255) 則 等 於 digitalWrite
(9,HIGH)。PWM 訊號顯示如
圖 16-15
。
圖 16-15
各種可行的 PWM 週期
您 可 以 用 這 個 指 令 以 不 同 的 頻 率 來 讓
LED 燈漸亮或漸暗。首先,您得準備一
條 電 線 將 LED 燈 接 到 支 援 PWM 腳 位
(例:腳位 9)的電路(
圖 16-16
)。
圖 16-16
接在 PWM 腳位上的 LED 燈
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