In the next section, we will see how to control a digital output from a web browser using
Rest commands. Let's dive into it, to see more details:
You can now either copy the code inside a file called outputcontrol.js, or just get the complete code from the folder for this project and execute it with Node.js. Open the terminal on your Raspberry Pi and type the following:
sudo node output control.js
We define the GPIO of the device importing the commands, by using the following:
var gpio = require('rpi-gpio');
Now we will create our web server using Node.js using the following lines.
We import the require packages that are necessary to run. We declare the libraries ...