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.
Start Visual Studio 2017 and create a new project (File | New Project…). In the
New Project dialog, navigate to
Basic Node.js Cylon Application (Universal Windows) template (shown below), enter a name for your project, then press OK.
Wait for the Cylon package and its dependencies to complete downloading. This will be indicated by the message below in the npm output window.
Right-click on the npm node in the Solution Explorer (shown below) and select Update npm Packages. This step will run npm dedupe and update serialport (a Cylon dependency) with a version that works with Node.js UWP.
Connect your Arduino and Raspberry Pi 2 or 3 with the USB cable. If your Raspberry Pi 2 or 3 is connected to a monitor, you should see the device getting recognized as shown in the image below (the name of the device may be something like “Arduino Uno” instead of “USB Serial Device”):
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. Since you’re building for Raspberry Pi 2 or 3, select
ARM in the dropdown menu.
Press F5 (or select Debug | Start Debugging) to deploy and start the app. When the app runs, it will output the names of ports that are attached to your Raspberry Pi (see image below). Make a note of the ID (value of ‘port.comName’ in the code above) for the Arduino since we’ll use it in the next step.
Attach the servo to the the arduino board using pin 3 (you can also change the pin number in app.js). In the setup shown below, the signal wire is connected to pin 3 and the power source is the Raspberry Pi.
Press F5 (or select Debug | Start Debugging) to deploy and start the app. This step will also start rotating the motor on the servo.