In previous Raspberry Pi Tutorials, we have used many different programming languages and softwares to control Raspberry Pi including Python, embedded C, Flask etc. To expand the horizon of powerful Raspberry Pi board, today we will use a very popular JavaScript based environment (Node.js) to control Raspberry Pi GPIOs locally as well as globally by setting it up as webserver. Initially, Node.js was developed for Google Chrome but later it was open-sourced by Google.
In this tutorial, we will control an LED, connected to Raspberry Pi, using two methods
- First we will simply write a JavaScript code using Node.js to Blink the LED
- In second method, we will create a HTML page with two buttons to turn on and off the LED. This HTML web page will be hosted on raspberry pi and can be opened on any web browser. So here Raspberry Pi will act as webserver