O'Reilly logo

Raspberry Pi LED Blueprints by Agus Kurniawan

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

Controlling LEDs and lamps using Node.js

In some previous chapters, we learned how to control sensor or actuator devices using Python. In this section, I will show you how to build a program using Node.js to control simple actuator devices, such as LEDs. There are many Node.js libraries, which are able to access Raspberry Pi GPIO. One of these libraries is rpi-gpio. You can find it at https://www.npmjs.com/package/rpi-gpio.

You can install rpi-gpio using the npm command:

$ npm install rpi-gpio

Your Raspberry Pi must be connected to an Internet network because Pi needs to download this module.

Another approach is that you can define your module dependencies on the package.json file. Just write this script into a file named package.json:

{ "name": ...

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