JavaScript on Things
Hardware for web developers
Lyza Danger Gardner
  • MEAP began July 2016
  • Publication in January 2018 (estimated)
  • ISBN 9781617293863
  • 486 pages (estimated)
  • printed in black & white

You can use JavaScript - the language of the web - to make things happen in the real world. JavaScript controls hordes of small robots, creative maker projects, and IoT products. Inexpensive platforms like the Raspberry Pi and Tessel 2 are powerful little computers in their own right, with the oomph to run Node.js on-board, and you can also use JavaScript to control simpler boards like the ubiquitous Arduino Uno. With the Node.js ecosystem at hand, hardware prototyping gets fun, intuitive and fast. Plug stuff in anything from motors to touch screens to soil moisture sensors and you're off! Let's build something!

JavaScript on Things is your first step into the exciting and downright entertaining world of programming for small electronics. If you know enough JavaScript to hack a website together, you'll be making things bleep, blink and spin faster than you can say "nodebot". This fully-illustrated, hands-on book shows you how to get going with platforms like Arduino, Tessel, and Raspberry Pi. You'll get a thorough crash course in basic electronics and go in-depth and step-by-step, building little projects that light up, sense the environment around you, make noise, exchange data, move around, and more. You'll even build a wirelessly-controlled robot. Yay! Learning something truly useful has never been quite this much fun. We guarantee it.

Table of Contents detailed table of contents

Part 1: A JavaScripter's Introduction to Hardware

1. Bringing JavaScript and hardware together

1.1. The Anatomy of Hardware Projects

1.1.1. Inputs and Outputs

1.1.2. Processing

1.1.3. Power, Circuits and Systems

1.1.4. Logic and Firmware

1.1.5. Enclosures and Packaging

1.1.6. Embedded Systems

1.2. How JavaScript and Hardware Work Together

1.2.1. Host-Client Method

1.2.2. Embedded JavaScript

1.2.3. Other Hardware-JavaScript Combinations

1.2.4. Cloud-based Services and the Browser

1.3. Is JavaScript a Good Fit for Hardware?

1.4. Putting Together A Hardware Toolkit

1.4.1. Development Boards

1.4.2. Input and Output Components

1.4.3. Other Electronic Components

1.4.4. Power, Wires and Accessories

1.4.5. Tools

1.5. Summary

2. Embarking on hardware with Arduino

2.1. Getting to Know Arduino Uno

2.1.1. Creating your First Circuit with Arduino Uno

2.2. Working with the Arduino Workflow

2.2.1. Arduino Uno's Digital Pins

2.2.2. Sketches and the Arduino IDE

2.2.3. Connecting the LED to a Digital Pin

2.3. Controlling the Arduino with JavaScript

2.3.1. Configuring the Arduino as a Client

2.3.2. Installing the Johnny-Five Node.js Framework

2.3.3. "Hello, World" Blinking LED with Johnny-Five

2.3.4. Firmata, Johnny-Five and the Host-Client Method

2.3.5. Structuring Scripts with Johnny-Five

2.4. Summary

3. How to build circuits

3.1. Voltage, Current and Resistance

3.1.1. Ohm's Law

3.1.2. Problems and Dangers

3.2. Building Circuits

3.2.1. Using Breadboards to Prototype Circuits

3.2.2. Wiring a Simple LED Circuit on a Breadboard

3.2.3. Expanding a Series Circuit with a Button

3.2.4. LEDs in Series

3.2.5. Parallel Circuits and Current Dividers

3.2.6. Powering your Project with Batteries

3.3. Summary

Part 2: Project Basics: Input and Output with johnnyfive

4. Sensors and input

4.1. Working with Analog Sensors

4.1.1. Analog-to-Digital Conversion

4.1.2. Working with Photoresistors

4.1.3. Voltage Dividers

4.1.4. Wiring and Using a Photoresistor

4.1.5. Using an Analog Temperature Sensor

4.2. Digital Inputs

4.2.1. Using a Button as a Digital Input

4.3. Summary

5. Output: making things happen

5.1. Lighting Things Up

5.1.1. Fading LEDs with Pulse-Width Modulation (PWM)

5.1.2. Animating LEDs with PWM

5.1.3. Combining Input with LED Output

5.1.4. Going Full-Color with RGB LEDs

5.1.5. Build your Own "Weather Ball"

5.2. Working with LCD Displays (Parallel)

5.2.2. Adding a Visual LED "Chime"

5.3. Making Noise with a Piezo

5.3.1. Adding an Audible Piezo Chime to the Timer

5.3.2. Playing Tunes on the Piezo

5.4. Summary

6. Output: making things move

6.1. Making Motors Spin

6.1.1. How Motors Work

6.1.2. Controlling a Motor with a Pushbutton Switch

6.1.3. Controlling a Motor with Johnny-Five

6.2. Making Servos Go

6.2.1. Controlling a Servo with Johnny-Five

6.3. Building Your First Robot!

6.3.1. Robots and Motors

6.3.2. Building the Robot’s Chassis Base

6.3.3. Controlling the Robot’s Motors

6.4. Summary

Part 3: More Sophisticated Projects

7. Serial communication

7.1. Communicating Digital Data in Parallel and in Serial

7.2. The Basics of Serial Communication

7.3. Asynchronous Serial Communication

7.3.1. UARTs

7.3.2. Trying Out Software Serial with a GPS Breakout Board

7.3.3. Learn to Solder!

7.3.4. Building the GPS Circuit

7.4. Sychronous Serial Communication

7.4.1. Serial Peripheral Interface (SPI)

7.4.2. I2C

7.4.3. Making a Digital Compass with an I2C Magnetometer

7.5. Pulling it Together: Shake-to-Change Multi-Sensor Widget

7.5.1. Step 1: Combining a Compass with LCD Output

7.5.2. Step 2: Adding A "Multi" Sensor to the Device

7.5.3. Step 3: Updating the Display to show Temperature and Pressure

7.5.4. Step 4: Adding a "Shake to Swap Display" Feature with an Accelerometer

7.6. Summary

8. Projects without wires

8.1. Why We’ve Been Tethered So Far

8.1.1. Data Exchange, the I/O Layer and I/O Plugins

8.1.2. USB as a Power Source

8.1.3. Options for Wires-Free Project Communication

8.2. Towards Wires-Free Projects using the Tessel 2

8.3. Getting your Tessel 2 Set Up

8.3.1. Configuring the Tessel

8.3.2. "Hello, World" LED Blinking on the Tessel

8.3.3. Blinking an External LED with the Tessel

8.3.4. Exploring the Tessel’s Pins and Capabilities

8.4. Projects without Wires on the Tessel 2

8.4.1. Wires-Free Data: A Remote Weather Station

8.5. Powering Projects with Batteries

8.5.1. A Battery-Powered Robot with the Tessel 2

8.6. Summary

9. Building your own thing

9.1. Hacking consumer electronics

9.1.1. Modifying RF-controlled outlet switches

9.2. Controlling the remote switches with a Johnny-Five component plugin

9.2.1. Prototyping the switch project

9.2.2. Writing the RemoteSwitch plugin

9.3. Writing software for sophisticated hardware

9.3.1. Project: Johnny-Five support for APDS-9660 gesture sensor

9.3.2. Implementing Constructor and initialization methods

9.3.3. Integrating the gesture sensor and remote switches

9.3.4. Pulling the whole project together

9.4. Summary

Part 4: Using JavaScript with Hardware in Other Environments

10. JavaScript and Constrained Hardware

10.1. The Espruino Pico Platform

10.1.1. Setting up the Pico

10.2. Learning About New Platforms

10.2.1. Understanding a Platform’s Core Features

10.2.2. Finding a Pinout Diagram

10.2.3. Grokking Configuration and Workflow

10.2.4. Find Examples and Tutorials

10.2.5. Using Reference API Documentation

10.3. Experimenting with the Pico

10.3.1. The Pico and the BMP180 Multi Sensor

10.3.2. The Pico and the Nokia 5110 LCD

10.3.3. Building a Power-Efficient Weather Gadget with the Pico

10.4. Experimenting with the Kinoma Element Platform

10.4.1. The Element’s Core Features

10.4.2. Pinout and Hardware Diagram

10.4.3. Configuration, Management, Workflow

10.4.4. Examples and Tutorials

10.4.5. API Reference

10.4.6. Case-Study Project: Live-Updating Compass Readings

10.5. Summary

11. Building with Node.js and Tiny Computers

11.1. Working with Tiny Computers

11.1.1. The Raspberry Pi Platform

11.1.2. Configuration Option 1: The Traditional Way

11.1.3. Configuration Option 2: Headless

11.2. Learning about the Raspberry Pi 3

11.2.1. Core Features

11.2.2. GPIO Features and Pinouts

11.2.3. Configuration and Workflow

11.2.4. Examples and Tutorials

11.2.5. API Documentation

11.3. Writing Johnny-Five Applications for Different Platforms

11.3.1. Adapting the Mini Weather Station for the Pi 3

11.3.2. Adapting the Mini Weather Station for the Arduino Uno

11.4. Using the Raspberry Pi as a Host

11.5. Case Study: BeagleBone Black

11.5.1. Learning about the BeagleBone Black

11.5.2. Adapting the Weather Station for the BeagleBone

11.6. Summary

12. In The Cloud, In the Browser, and Beyond

12.1. IoT and the Cloud

12.2. Containerized Deployment with Resin.io

12.2.1. Creating a Resin.io Application

12.2.2. Provisioning the BeagleBone Black

12.2.3. Adapting the Weather Application Software

12.3. Hardware and the Web Browser

12.3.1. The Web Bluetooth API

12.3.2. The Generic Sensor API

12.3.3. The Physical Web

12.4. Exploring Bluetooth LE with Puck.js

12.4.1. Core Features

12.4.2. GPIO Features and Pinouts

12.4.3. Configuration and Workflow

12.4.4. Examples, Tutorials and API Documentation

12.4.5. Controlling the LED from a Web Page

12.4.6. The Physical Web and Puck.js

12.4.7. A Web-based Bluetooth Doorbell

12.5. Pushing the Frontiers of JavaScript and Hardware

12.6. Summary

What's inside

  • Using JavaScript in tandem with popular platforms like Arduino, Tessel 2 and Raspberry Pi
  • Introduction to creating and controlling embedded projects
  • Designing and assembling straightforward robots and gadgets
  • Crash course in basic electronics
  • Over a dozen hands-on projects

About the reader

Written for readers with intermediate JavaScript and Node.js skills. No experience with embedded systems or robotics required.

About the author

Lyza Danger Gardner has been web developer for over 20 years. She's part of the nodebots community and is a contributor to the johnny-five Node.js library.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
Buy
MEAP combo $39.99 pBook + eBook + liveBook
MEAP eBook $31.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks