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

Project – the continuous servo


Continuous servos are a little like a motor combined with a regular servo: you lose the ability to go to specific degrees like a regular servo, but you can stop instantly instead of coasting to a stop like many motors. You can tell a continuous servo to move clockwise or counterclockwise at different speeds, and you can tell it to stop.

Let's wire up a continuous servo and play with its abilities via the Johnny-Five REPL.

 

Wiring up the servo

The only difference in the wiring is continuous servos look different from regular servos in that nearly all have a disc instead of a horn. And most have red, white, and black power, signal, and ground wires, respectively.

(Fritzing didn't have a continuous servo object, so we'll have to make due.)

 

Continuous servo constructor and methods

The constructor for the continuous servo is reminiscent of the RGB LED constructor, in that it is a property of the Servo object. Otherwise, it looks very similar to the Servo constructor...