Reader small image

You're reading from  Learning JavaScript Robotics

Product typeBook
Published inNov 2015
Reading LevelIntermediate
Publisher
ISBN-139781785883347
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Kassandra Perch
Kassandra Perch
author image
Kassandra Perch

Kassandra Perch is an open web developer and supporter. She began as a frontend developer and moved to server-side with the advent of Node.js and was especially enthralled by the advance of the NodeBots community. She travels the world speaking at conferences about NodeBots and the fantastic community around them.
Read more about Kassandra Perch

Right arrow

Johnny-Five sensor events


As discussed in the previous chapters, Johnny-Five is dependent on events for a lot of its functionality. This is not different for inputs and sensors—most of the time, you'll interact with these by waiting for events. While most input devices have ways way to read data at any given moment, these are mostly used for debugging, and you'll need to have a good grasp of the events available for your input device or sensor when coding your projects.

Most input devices and sensors have a data event; this event tells the program when data is read from the device. This is a kind of a firehose: it reports quite quickly and can be a little overwhelming. This is usually used for debugging, as most robotics programs are more interested in when the sensor or input data changes rather than when there is new input to be read.

The change event, also available on most devices, is a very commonly-used event—it only fires when the incoming data has changed. A good example is a temperature...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning JavaScript Robotics
Published in: Nov 2015Publisher: ISBN-13: 9781785883347

Author (1)

author image
Kassandra Perch

Kassandra Perch is an open web developer and supporter. She began as a frontend developer and moved to server-side with the advent of Node.js and was especially enthralled by the advance of the NodeBots community. She travels the world speaking at conferences about NodeBots and the fantastic community around them.
Read more about Kassandra Perch