concept gesture sensor in category javascript

This is an excerpt from Manning's book JavaScript on Things: Hacking hardware for web developers.
Figure 9.12. The APDS-9960 crams three sensors into one package, including a gesture sensor. SparkFun offers a breakout board that makes working with the chip easier.
![]()
The problem is, at the time I stumbled upon the APDS-9960, there was no preexisting Johnny-Five support for it. There’s no component class for gesture sensors. That means you need to create that support! When preexisting software doesn’t exist for something you want to use, you’ve got two options: substitute another piece of hardware that does have support, or create that support yourself.
Run index.js on the Tessel (t2 run index.js --lan) and try moving your hand over the top of the gesture sensor—the best distance is around eight inches (20 cm).
You’ve already got the ingredients to control individual on/off switch combinations using the gesture sensor and RemoteSwitch. For example, you could do something like what’s shown in the following listing.
Listing 9.16. APDS9960 controlling a single switch with the gesture sensor
const five = require('johnny-five'); const Tessel = require('tessel-io'); const Gesture = require('./APDS9960')(five); const RemoteSwitch = require('./RemoteSwitch')(five); const board = new five.Board({ io: new Tessel() }); board.on('ready', () => { const gesture = new Gesture({ pin: 'A2'}); const switch1 = new RemoteSwitch({ pins : { on: 'A3', off: 'A4' } }); gesture.on('right', () => switch1.on()); gesture.on('left', () => switch2.on()); });