Book Image

Hands-On Robotics with JavaScript

By : Kassandra Perch
Book Image

Hands-On Robotics with JavaScript

By: Kassandra Perch

Overview of this book

JavaScript has an effective set of frameworks and libraries that provide support for embedded device programming and the robotics ecosystem. You’ll be able to put your JavaScript knowledge to work with this practical robotics guide. The book starts by guiding you in setting up an environment to program robots with JavaScript and Rasberry Pi 3. You will build beginner-level projects, such as a line-following robot, and then upgrade your robotics skills with a series of projects that help you get to grips with the Johnny-Five library. As you progress, you’ll learn how you can improve your projects by enabling advanced hardware components and programming concepts. You’ll even build an advanced AI-enabled robot, connect its NodeBots to the internet, create a NodeBots Swarm, and explore Message Queuing Telemetry Transport (MQTT). By the end of this book, you will have enhanced your robot programming skills by building a range of simple to complex projects.
Table of Contents (19 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Adding buttons to our RGB LED project


Now that we know how buttons work and how to wire one up to the Pi, let's add two buttons to our RGB LED project.

Wiring everything up

Before we wire up our buttons, we're going to need to do some housekeeping on our current wiring setup.

Using the power and ground side rails

From here on, we'll be needing more access to power and GND pins, and we don't want a ton of really long wires criss-crossing our projects. So the first thing we'll do is a little hardware refactoring. 

  1. Take the RGB LED ground off the cobbler row.

 

  1. Take the VCC and GND from the GPIO expander off the 5V and GND cobbler rows.
  2. Place a wire between the 5V row of the cobbler and the outer long row (if there's one marked red and one blue, use red).
  3. Place a wire between a GND pin of the cobbler and the other outer row.
  4. Plug the RGB LED ground into the side rail you linked to the GND on the cobbler.
  5. Plug the GND from the GPIO expander into the side rail linked to GND on the cobbler, and the VCC into...