Preface |
|
xii | |
Acknowledgments |
|
xv | |
About this book |
|
xvii | |
|
PART 1 A JAVASCRIPTER'S INTRODUCTION TO HARDWARE |
|
|
1 | (78) |
|
1 Bringing JavaScript and hardware together |
|
|
3 | (23) |
|
1.1 The anatomy of hardware projects |
|
|
4 | (7) |
|
|
5 | (1) |
|
|
6 | (1) |
|
Power, circuits, and systems |
|
|
6 | (2) |
|
|
8 | (2) |
|
|
10 | (1) |
|
|
10 | (1) |
|
1.2 How JavaScript and hardware work together |
|
|
11 | (8) |
|
|
11 | (4) |
|
|
15 | (1) |
|
Other hardware-JavaScript combinations |
|
|
16 | (3) |
|
1.3 Is JavaScript a good fit for hardware? |
|
|
19 | (1) |
|
1.4 Putting together a hardware toolkit |
|
|
20 | (6) |
|
|
20 | (1) |
|
Input and output components |
|
|
21 | (1) |
|
Other electronic components |
|
|
22 | (1) |
|
Power, wires, and accessories |
|
|
23 | (1) |
|
|
23 | (3) |
|
2 Embarking on hardware with Arduino |
|
|
26 | (22) |
|
2.1 Getting to know the Arduino Uno |
|
|
28 | (5) |
|
Creating your first circuit with an Arduino Uno |
|
|
30 | (3) |
|
2.2 Working with the Arduino workflow |
|
|
33 | (6) |
|
Arduino Uno's digital pins |
|
|
33 | (1) |
|
Sketches and the Arduino IDE |
|
|
34 | (2) |
|
Connecting the LED to a digital pin |
|
|
36 | (1) |
|
Programming the LED to blink |
|
|
37 | (2) |
|
2.3 Controlling the Arduino with JavaScript |
|
|
39 | (9) |
|
Configuring the Arduino as a client |
|
|
40 | (2) |
|
Installing the Johnny-Five Node.js framework |
|
|
42 | (1) |
|
Hello World blinking LED with Johnny-Five |
|
|
43 | (1) |
|
Firmata, Johnny-Five, and the host-client method |
|
|
44 | (1) |
|
Structuring scripts with Johnny-Five |
|
|
45 | (3) |
|
|
48 | (31) |
|
3.1 Voltage, current, and resistance |
|
|
49 | (8) |
|
|
53 | (3) |
|
|
56 | (1) |
|
|
57 | (22) |
|
Using breadboards to prototype circuits |
|
|
57 | (1) |
|
Wiring a simple LED circuit on a breadboard |
|
|
58 | (7) |
|
Expanding a series circuit with a button |
|
|
65 | (2) |
|
|
67 | (4) |
|
Parallel circuits and current dividers |
|
|
71 | (5) |
|
Powering your project with batteries |
|
|
76 | (3) |
|
PART 2 PROJECT BASICS: INPUT AND OUTPUT WITH JOHNNY-FIVE |
|
|
79 | (100) |
|
|
81 | (26) |
|
4.1 Working with analog sensors |
|
|
84 | (17) |
|
Analog-to-digital conversion |
|
|
84 | (1) |
|
Working with photoresistors |
|
|
85 | (4) |
|
|
89 | (3) |
|
Wiring and using a photoresistor |
|
|
92 | (5) |
|
Using an analog temperature sensor |
|
|
97 | (4) |
|
|
101 | (6) |
|
Using a button as a digital input |
|
|
101 | (6) |
|
5 Output: making things happen |
|
|
107 | (37) |
|
|
109 | (16) |
|
Fading LEDs with pulse-width modulation (PWM) |
|
|
109 | (5) |
|
|
114 | (3) |
|
Combining input with LED output |
|
|
117 | (4) |
|
Going full-color with RGB LEDs |
|
|
121 | (1) |
|
Build your own "weather ball" |
|
|
122 | (3) |
|
5.2 Working with parallel LCD displays |
|
|
125 | (14) |
|
Making a full-featured timer with LCD |
|
|
125 | (11) |
|
Adding a visual LED "chime" |
|
|
136 | (3) |
|
5.3 Making noise with a piezo |
|
|
139 | (5) |
|
Adding an audible piezo chime to the timer |
|
|
141 | (3) |
|
6 Output: making things move |
|
|
144 | (35) |
|
|
146 | (9) |
|
|
146 | (2) |
|
Controlling a motor with a push-button switch |
|
|
148 | (4) |
|
Controlling a motor with Johnny-Five |
|
|
152 | (3) |
|
|
155 | (6) |
|
Controlling a servo with Johnny-Five |
|
|
157 | (4) |
|
6.3 Building your first robot! |
|
|
161 | (18) |
|
|
162 | (2) |
|
Building the robot's chassis base |
|
|
164 | (2) |
|
Controlling the robot's motors |
|
|
166 | (13) |
|
PART 3 MORE SOPHISTICATED PROJECTS |
|
|
179 | (116) |
|
|
181 | (33) |
|
7.1 Communicating digital data in parallel and in serial |
|
|
183 | (1) |
|
7.2 The basics of serial communication |
|
|
184 | (1) |
|
7.3 Asynchronous serial communication |
|
|
185 | (11) |
|
|
187 | (2) |
|
Trying out software serial with a GPS breakout board |
|
|
189 | (1) |
|
|
190 | (4) |
|
|
194 | (2) |
|
7.4 Synchronous serial communication |
|
|
196 | (6) |
|
Serial Peripheral Interface (SPI) |
|
|
197 | (1) |
|
|
198 | (2) |
|
Making a digital compass with an I2C magnetometer |
|
|
200 | (2) |
|
7.5 Pulling it together: shake-to-change multisensor widget |
|
|
202 | (12) |
|
Step 1 Combining a Compass with LCD Output |
|
|
203 | (3) |
|
Step 2 Adding a Multisensor to the Device |
|
|
206 | (2) |
|
Step 3 Updating the Display to Show Temperature and Pressure |
|
|
208 | (1) |
|
Step 4 Adding a Shake-to-Swap Display Feature with an Accelerometer |
|
|
209 | (5) |
|
|
214 | (39) |
|
8.1 Why you've been tethered so far |
|
|
217 | (3) |
|
Data exchange, the I/O layer, and I/O plugins |
|
|
217 | (1) |
|
|
217 | (2) |
|
Options for wires-free project communication |
|
|
219 | (1) |
|
8.2 Toward wires-free projects using the Tessel 2 |
|
|
220 | (1) |
|
8.3 Getting your Tessel set up |
|
|
221 | (9) |
|
|
222 | (2) |
|
"Hello World" LED blinking on the Tessel |
|
|
224 | (1) |
|
Blinking an external LED with the Tessel |
|
|
225 | (4) |
|
Exploring the Tessel's pins and capabilities |
|
|
229 | (1) |
|
8.4 Projects without wires on the Tessel |
|
|
230 | (14) |
|
Wires-free data: a remote weather station |
|
|
231 | (13) |
|
8.5 Powering projects with batteries |
|
|
244 | (9) |
|
A battery-powered robot with the Tessel |
|
|
246 | (7) |
|
9 Building your own thing |
|
|
253 | (42) |
|
9.1 Hacking consumer electronics |
|
|
255 | (8) |
|
Modifying RF-controlled outlet switches |
|
|
255 | (8) |
|
9.2 Controlling the remote switches with a Johnny-Five component plugin |
|
|
263 | (9) |
|
Prototyping the switch project |
|
|
263 | (3) |
|
Writing the RemoteSwitch plugin |
|
|
266 | (6) |
|
9.3 Writing software for sophisticated hardware |
|
|
272 | (23) |
|
Project: Johnny-Five support for APDS-9660 gesture sensor |
|
|
272 | (12) |
|
Implementing constructor and initialization methods |
|
|
284 | (5) |
|
Integrating the gesture sensor and remote switches |
|
|
289 | (3) |
|
Pulling the whole project together |
|
|
292 | (3) |
|
PART 4 USING JAVASCRIPT WITH HARDWARE IN OTHER ENVIRONMENTS |
|
|
295 | (120) |
|
10 JavaScript and constrained hardware |
|
|
297 | (35) |
|
10.1 The Espruino Pico platform |
|
|
299 | (4) |
|
|
300 | (2) |
|
|
302 | (1) |
|
10.2 Learning about new platforms |
|
|
303 | (5) |
|
Discovering a platform's core features |
|
|
303 | (3) |
|
|
306 | (1) |
|
Learning about configuration and workflow |
|
|
307 | (1) |
|
Finding examples and tutorials |
|
|
307 | (1) |
|
Using reference API documentation |
|
|
307 | (1) |
|
10.3 Experimenting with the Pico |
|
|
308 | (12) |
|
The Pico and the BMP 180 multisensor |
|
|
308 | (2) |
|
The Pico and the Nokia 5110 LCD |
|
|
310 | (7) |
|
Building a power-efficient weather gadget with the Pico |
|
|
317 | (3) |
|
10.4 Experimenting with the Kinoma Element platform |
|
|
320 | (12) |
|
The Element's core features |
|
|
320 | (1) |
|
Pinout and hardware diagram |
|
|
321 | (1) |
|
Configuration, management, workflow |
|
|
321 | (1) |
|
|
322 | (1) |
|
|
323 | (1) |
|
Case-study project: live-updating compass readings |
|
|
323 | (9) |
|
11 Building with Node.js and tiny computers |
|
|
332 | (43) |
|
11.1 Working with tiny computers |
|
|
335 | (10) |
|
The Raspberry Pi platform |
|
|
336 | (4) |
|
Configuration option 1: the traditional way |
|
|
340 | (1) |
|
Configuration option 2: headless |
|
|
341 | (4) |
|
11.2 Learning about the Raspberry Pi 3 |
|
|
345 | (12) |
|
|
345 | (1) |
|
GPIO features and pinouts |
|
|
346 | (2) |
|
Configuration and workflow |
|
|
348 | (3) |
|
|
351 | (6) |
|
|
357 | (1) |
|
11.3 Writing Johnny-Five applications for different platforms |
|
|
357 | (8) |
|
Adapting the mini weather station for the Pi 3 |
|
|
358 | (6) |
|
Adapting the mini weather station for the Arduino Uno |
|
|
364 | (1) |
|
11.4 Using the Raspberry Pi as a host |
|
|
365 | (1) |
|
11.5 Case study: BeagleBone Black |
|
|
366 | (9) |
|
Learning about the BeagleBone Black |
|
|
367 | (5) |
|
Adapting the weather station for the BeagleBone |
|
|
372 | (3) |
|
12 In the cloud, in the browser, and beyond |
|
|
375 | (40) |
|
|
377 | (1) |
|
12.2 Containerized deployment with resin.io |
|
|
378 | (10) |
|
Creating a resin.io application |
|
|
380 | (2) |
|
Provisioning the BeagleBone Black |
|
|
382 | (1) |
|
Adapting the weather application software |
|
|
383 | (5) |
|
12.3 Hardware and the web browser |
|
|
388 | (3) |
|
|
389 | (1) |
|
|
389 | (1) |
|
|
390 | (1) |
|
12.4 Exploring Bluetooth LE with Puck.js |
|
|
391 | (22) |
|
|
391 | (1) |
|
GPIO features and pinouts |
|
|
392 | (1) |
|
Configuration and workflow |
|
|
393 | (2) |
|
Examples, tutorials, and API documentation |
|
|
395 | (1) |
|
Controlling the LED from a web page |
|
|
395 | (5) |
|
The Physical Web and Puck.js |
|
|
400 | (2) |
|
A web-based Bluetooth doorbell |
|
|
402 | (11) |
|
12.5 Pushing the frontiers of JavaScript and hardware |
|
|
413 | (2) |
Index |
|
415 | |