Skip to Content
Node.js物聯網裝置開發
book

Node.js物聯網裝置開發

by Patrick Mulder, Kelsey Breseman
August 2017
Intermediate to advanced
272 pages
5h 32m
Chinese
GoTop Information, Inc.
Content preview from Node.js物聯網裝置開發
Johnny-Five 程式庫
|
123
console.log("The obstruction has moved.");
});
});
Nodebot 類別
Johnny-Five 這套程式庫,當初設計時便以機器人為考慮對象,嘿,運用它的
Nodebot
別的話,只需底下 12 行程式碼,就能控制一台簡單的機器人囉:
// simple_nodebot.js
var five, Nodebot;
five = require("johnny-five");
five.Board().on("ready", function() {
Nodebot = new five.Nodebot({
right: 10,
left: 11
});
this.repl.inject({
n: Nodebot
});
})
這支程式啟動後會出現 REPL 介面,讓你控制機器人。以此例而言,機器人擁有兩個伺
服馬達,負責移動。若想在連接序列埠的情況下進行測試,那麼最好把機器人放在輪子
不著地的地方,才不會亂跑。
關於機器人的建構,第 12 章還會進一步介紹。
I2C 程式庫
與透過 UART 的序列傳輸相比,I2C 的傳輸方式稍微複雜一點。許多感測器與電子零
件,都支援 I2C,因為可在同一條匯流排線路上,連接多個 I2C 感測器,總共只需 2
線路而已,非常精簡。
I2C 匯流排屬於
半雙工
half-duplex
)傳輸介面,意思是說,線路上的兩個節點只
輪流
進行傳輸作業,某一節點扮演稱為「主方(master
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

金融人工智能:用Python实现AI量化交易

金融人工智能:用Python实现AI量化交易

Yves Hilpisch
快学熟用D3

快学熟用D3

Philipp K. Janert

Publisher Resources

ISBN: 9789864764594