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 自造手冊:新工業革命實務指南
第 17 章 擴充 Arduino
168
圖 17-6
用 100 歐姆的電阻將蜂鳴器與 Arduino
串聯。
警告
除了 Arduino Mega 之外,其他板
子在執行
tone 函式時都會干擾 3
號與 11 號腳位的 PWM 功能。
伺服機
伺服機是另一種將電力轉變為機械動能
的致動器,這是一種特殊的馬達,可以
將連接的伺服臂移動、固定給特定位置,
一般來說動作可以達到 90 或 180 度。伺
服臂的應用範圍很廣,例如,將洋娃娃
變成可以獨立動作的機器娃娃。我們將
試著製作一組有伺服機和電位計、且可
以讓您自由控制的電路(
圖 17-7
)。
圖 17-7
由電位計控制的伺服機
多虧有 Servo 函式庫來管理驅動擺臂的
PWM 訊號,讓 操作伺 服機變 得 超簡單
(
範例 17-2
)。
範例 17-2
用電位計控制伺服機
#include <Servo.h>
Servo myservo;
int position = 0;
void setup()
{
myservo.attach(9);
}
void loop()
{
int pos = analog Read(A0);
position = map(pos, 0, 1023, 0, 180);
myservo.write(position);
delay(100);
}
使 用 #include<Servo.h>; 匯 入 函 式 庫 之
後,在草稿碼中建立一個名為 myservo
的 變 數, 它 在 程 式 中 就 代 表 您 的 伺 服
機。在 setup()
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