In this project, we will use Windows Remote Arduino to turn an LED on and off. It is a simple example, but will reveal the power that the library can give you to create many more advanced projects. Let’s get started!
You can download the "samples" repository here. This sample is "RemoteBlinky" inside the appropriate platform folder, either Win10 or Win8.1. Make sure to clone the repository recursively so that you also obtain a copy of the library (more info in the readme)! The downloadable sample includes code for both USB and Bluetooth connections, while this guide mainly covers Bluetooth (with some short USB asides) since it involves extra hardware steps and is just so much more awesome.
It is also possible to connect to your Arduino through the network, but you'll require a WiFi shield or Ethernet shield. Further instructions can be found on the Windows Remote Arduino repository page, linked directly below.
If you'd prefer to create your own project, follow the project set up guide here
You can find the Windows Remote Arduino repository here
First thing's first, let's program the Arduino.
- Download and install the Arduino software from http://arduino.cc.
- Connect your Arduino device to the computer using USB.
- Launch the Arduino application.
- Verify that you have the correct Arduino board selected under Tools > Board
- Verify that you have the correct COM Port selected under Tools > Port
- In the Arduino IDE, navigate to File > Examples > Firmata > StandardFirmata
- Verify that StandardFirmata will use the correct baud rate for your connection. (See note on baud rate below)
- Press “Upload” to deploy the StandardFirmata sketch to the Arduino device.
StandardFirmata uses the Serial lines to talk to a Bluetooth device or over USB. By default, it uses a baud rate of 57,600 bps. Depending on the configuration of your Bluetooth device, you may need to modify that rate. It can be found in the
method and looks like this:
Change this value to the correct baud rate. For USB, this value is configurable on both the device and in the Windows Remote Arduino connection parameters. If you are using Bluetooth, the baud rate depends on the device you are using.
You can always use a USB, WiFi, or Ethernet connection to get started, but let’s cover simple hook up of a Bluetooth device and an LED that we will turn on and off over Bluetooth using the Windows Remote Arduino library!
- Connect the power and ground rails on the breadboard to the 5V and GND pins, respectively, on the Arduino. Using color coded wires (red and black) will make it easy to keep track of the power connections.
- Plug your bluetooth device on the breadboard and connect the VCC and GND pins to the power and ground rails, respectively, on the breadboard.
- Connect the TX-0 pin on the bluetooth device to the RX pin on the Arduino. Similarly, connect the RX-1 pin on the bluetooth device to the TX pin on the Arduino.
- Notice the yellow wire in the image goes from the transmit pin of the bluetooth device to the receive pin of the Arduino and vice versa for the orange wire. This step is critical to establish serial communication between the bluetooth device and the Arduino, allowing the messages transmitted from one device to be received by the other.
- Make sure that your code is already uploaded on the Arduino before making this connection. The Arduino Uno uses the same serial (TX and RX) pins for flashing the device, which prevents any code from being uploaded to it when another device is connected to these serial pins.
- Add an LED to the breadboard. Note that the longer (or bent) leg is the anode (positive) and the shorter leg is the cathode (negative).
- Connect the cathode of the LED to the ground rail of the breadboard using a 330Ω resistor. A 330Ω resistor is striped orange, orange, brown, gold as shown in the image.
- Connect the anode of the LED to any digital I/O pin on the Arduino. We are using pin 13 in the example.
- You setup is now ready! It should look similar to the setup shown in the image below.
Arduino Sketch (Firmata)
Install Arduio Firmata Library:
Goto Sketch menu / Include Library / Manage Library and search for "Firmata" and install latest version of the library.
Now open & upload "StandardFirmata" example from File / Examples / Firmata / StandardFirmata.
It's done at Arduino side. Now we will see for Windows Universal Platform App.
Windows Universal Platform App
Now that we’re all set up, let’s get into some code!
- Create your project
I’ve set up a project called RemoteBlinky by following the steps in the setup guide. In the screenshot below, you will see the code-behind file MainPage.xaml.cs which simply creates a Bluetooth connection object and passes it to the RemoteDevice class in the constructor. You’ll see that I’ve specified my device name in this example. You may also enumerate the available devices by invoking the static
function on BluetoothSerial (and USBSerial) class before constructing your object.
has many options available to specify your device. In the constructor, you can provide the VID and PID of your device, the VID only, or a
object (obtained from the above mentioned
allows you to provide a device id (as a string), device name (also a string), or the
You can obtain the VID & PID combination of your USB device by following these steps:
- Open Device Manager through the Control Panel or by pressing both Windows + Pause keys and choosing the Device Manager link on the left.
- Expand the Ports (COM & LPT) menu
- Right-click your Arduino Device and select Properties
- On the Details tab, select Hardware Ids from the drop-down menu.
- You may see multiple entries in the Value box, but any entries will have matching PID and VID.
- The entries will have the format "USB\VID_****&PID_****" where **** are the numeric ID values.
USBSerial usb = new USBSerial( "VID_2341", "PID_0043" );
is guaranteed to work only for the following hardware device:
Next, I’m going to add a callback function to the DeviceReady event on the RemoteDevice object. This function will automatically be called when the Bluetooth device is connected and all necessary settings have been initialized. You’ll notice that I haven’t implemented anything in that function at this time. Last, call
.begin() on the connection object to tell it to connect.
The parameters to the
.begin() function do not matter for Bluetooth, but you must use the same baud rate on both the Arduino and the UsbSerial object (first parameter). Also, the 2nd parameter must be "
SerialConfig.8N1". The rest of the example will work exactly the same regardless of which connection type you are using.
- Jump over to the MainPage.xaml file and create a couple buttons that will turn an LED on and off. You’ll notice I’ve added button callbacks to the
Clickevent & set the
IsEnabledproperty to false, and you’ll see why in the next step!
- I’ve implemented three functions in this step. First, the
OnDeviceReadyfunction now enables the buttons on the UI thread! This guarantees that the buttons will be enabled only when the Bluetooth connection is ready, as it typically takes a few seconds for this to happen.
- I’ve also set up the
.digitalWrite()calls in the button callbacks
- Build and deploy! Your buttons will be enabled when the connection is established, and you can freely toggle your LED on and off at will! Here is a screenshot of this basic example running on Windows Phone 10.
I really hope you enjoy replicating this project and using it as a baseline for an incredible new set of Maker projects!
Windows Remote Arduino Samples
- 7 projects
- 2,018 followers
- 4 projects
- 34 followers
- 3 projects
- 82 followers
Published onMay 3, 2015
Members who respect this project
Project replicated by
you might like