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

Looking at the LED and LED.RGB API


We took a brief look at the LED API in Johnny-Five in the last chapter, but in this chapter, we will delve deeper and talk about the PWM output and the cousin of the standard LED, the RGB LED—so named because it has a red, green, and blue channel, and can replicate thousands of colors. We will use an RGB LED, as well as some of the more powerful tools built into Johnny-Five, to build an interactive project in this chapter.

The LED object

The LED object is usually the first thing in Johnny-Five that people look through the documentation for. It's also a great object to use to outline the general structure of the object documentation. Let's take a look at each section and get a grasp of where we should look for what later:

  • Parameters: This section addresses the parameters that need to be passed into the object constructor, and what form they need to be in (order, object key, and so on).
  • Shapes: These are the fields attached to the constructed object that may...