Create a blinky Node.js server that blinks an LED.
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.
Your session has expired. Please sign-in again to continue. Unfortunately any unsaved changes will be lost.