Create a blinky Node.js server that blinks an LED.
This sample only works with the Windows 10 IoT Core Anniversary Update (Build 14393) release with Visual Studio 2015 and does not currently work with any newer Windows releases or Visual Studio 2017. We are looking into adding Node.js support to UWP in a future release of Windows 10 IoT Core.
The setup for this sample is the same as the C# ‘Blinky’ sample.
Start Visual Studio 2017 and create a new project (File | New Project…). In the
New Project dialog, navigate to
Basic Node.js Web Server (Windows Universal) template.
When the project has been created, open up server.js and replace the existing code with the code shown below:
Here’s what the code above is doing:
GpioController.getDefault()is called to get the GPIO controller.
GpioController.openPin()with the LED pin value.
pin, we set it to be off (high) by default using the
Go to the Project menu and select ‘<Your project name> Properties’ (You could also right-click on the project node in solution explorer to access Properties). Enter the IP Address in the Remote Machine text box. If you’re building for Minnowboard Max, select
x86 in the dropdown. If you’re building for Raspberry Pi 2 or 3, select
Now we’re ready to deploy to the remote Windows IoT Core device. Simply press F5 (or select Debug | Start Debugging) to start debugging the server.
When the server is running, open up a browser and enter the address http://<IP address of your device>:1337. Refreshing the page will turn toggle the on/off state of the LED. Note: If you are using Microsoft Edge or Google Chrome, two requests may be sent for each refresh which will keep the LED from changing.