Skip to content

Windows Phone

Windows 10 IoT Core – Waving hands


As I noted in a previous post, Ian Philpot and I presented using Windows 10 IoT core. This project is currently being hosted here.

Getting Started

Getting started with this project I setup the Windows 10 IoT core device using this setup guide with a Raspberry Pi 2. Then I setup my development environment using this guide. Once setup it was time to create the project. There are multiple options for creating an IoT core project and in our case, because we wanted a UI component if we needed it, we settled for a Windows 10 Blank App.

IoT Core Setup

blank windows universal app

Once the new project is created, add the IoT core extensions to the project.

iot extensions

After it is ready to go for IoT development, its time to explain the architecture.


  • A listener in Azure (created by SignalR) is listening for notifications that the arm has moved and will send which direction it moved to all subscribers.
  • A windows phone is using a Micorosoft Band connects to azure and sends the band’s y position to the listener in Azure.
  • A Kinect is run from a desktop and sends detected arm movement from its field of vision to the listener in Azure.
  • The Windows 10 IoT Core device subscribes to the Azure SignalR instance and listens for notifications that the arm had moved and drives the servo accordingly.

IoT Core Implementation

The following will focus on the IoT Core piece as that was the part I focused on. It contained two sections of functionality:

  • SignalR client
  • Servo Driver

The SignalR client was simple enough. It can be added via NuGet and setup using this guide.

signalr nuget

After installing the package, the SignalR client and the servo driver were initialized in the MainPage.xaml.cs. Once initialized the client listens for “left” or “right” and drives the servo accordingly. Take note that the MainPage actually has a view for you to test the functionality of the project. Check there and debug the SignalR callback to verify that the client is listening to incoming pushes and can drive the peripheral hardware appropriately.

The servo itself is driven by a waveform function generated utilizing the I/O pin functionality as seen here. One interesting piece of code is the following:

private void ServoBackgrounTask(IAsyncAction action)
    //This motor thread runs on a high priority task and loops forever to pulse the motor as determined by the drive buttons
    while (true)
        if (_currentPulseWidth >= 0)
            //If a button is pressed the pulsewidth is changed to cause the motor to spin in the appropriate direction
            //Write the pin high for the appropriate length of time
            if (_currentPulseWidth != 0)
            //Use the wait helper method to wait for the length of the pulse
            //The pulse if over and so set the pin to low and then wait until it's time for the next pulse
            Wait(_servoPulseModel.PulseFrequency - _currentPulseWidth);

//A synchronous wait is used to avoid yielding the thread 
//This method calculates the number of CPU ticks will elapse in the specified time and spins
//in a loop until that threshold is hit. This allows for very precise timing.
private void Wait(double milliseconds)
    double desiredTicks = milliseconds / 1000 * Stopwatch.Frequency;
    Stopwatch stopwatch = Stopwatch.StartNew();
    while (stopwatch.ElapsedTicks < desiredTicks)


If the synchronous wait is removed (for say an async await approach) then the thread will detach and be terminated. The above solution, when written, was the only solution to allow for the servo to receive the proper waveform.

Speaking at .NET and Windows user’s groups

This monday (September 28, 2015), I will be speaking at the .NET user’s group in Atlanta. The topic will be the one described in this post.

The following monday (October 5, 2015), I will be speaking at the Atlanta Windows App Group. It will be general workshop for IoT.

Twitter Auto Publish Powered By :