O'Reilly logo

Learning JavaScript Robotics by Kassandra Perch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using sensors – Light and Temperature

Now, we'll build a couple of projects that demonstrate how to use more advanced sensors: a photocell and a temperature sensor. We'll learn how specialized Johnny-Five Sensor objects allow us to make these easier to use, and how to play with inputs in the REPL and show some input data in the console using a module called barcli.

Wiring up our photocell

First, we'll start with the photocell—see the following wiring diagram:

Wiring up our photocell

The wiring diagram for the photocell

Tip

Note that the resistor setup is how we wire up a sensor with only two leads and we need three—input, power, and ground.

Coding our photocell example

As we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required