Page 58 - MSDN Magazine, May 2017
P. 58

Figure 4 App Portal Showing the Installed App
Then, run the Raspberry Pi. On the Solution Platform drop- down, select ARM, and on the Device dropdown, select Remote Machine. A dialog box opens to select the
remote machine.
for the UWP Community Toolkit, a toolkit of components developed by Microsoft and the community, which definitely is worth checking out at bit.ly/2b1PAJY.
If you download the package and compile it, you can deploy it to the Raspberry Pi and run it (yes, you can run the program in the exact same way you would on a desktop). By the way, you should try using the controls in the device—they work fine.
Interacting with
the Board
Once you have your programs running, you must start interact- ing with the board. You’ll create a traffic light controller. It will have three LEDS (red, yellow and green) and there can be different timings for each light.
To operate on the LEDs in the board, you must get the GPIO Controller and open the pin you want to control and set it the way you want. In Figure 1, you see that the eighth pin in the GPIO block (second row) is pin 22. You’ll use pins 22, 9,
and 19, and the resulting circuit will be like the one shown in Figure 5. With this circuit in place, create a new blank UWP app. In Main- Page.xaml, input the code shown in Figure 6. You’ll see the traffic lights both on the board and on the display, so you can also see what’s happening by viewing the remote dis- play. The source code in Mainpage.xaml.cs
Select the Raspberry Pi device and run the application. The app will be deployed to the Raspberry Pi and you can see it run- ning in the remote control window. Note that the machine name shown in the win- dow should be the one you have set when you formatted the SD card and installed Windows 10 on it.
Youcandebugthisappthesamewayyou do with local apps—set breakpoints, ana- lyze variables and so on. If you terminate the app in Visual Studio, you’ll see that the app closes and the main screen appears in the Raspberry Pi. If you go to the browser portal, you’ll see that the app is still installed and can be run by using the Run button, as shown in Figure 4.
I’m amazed at the level of compatibility achieved with UWP apps. To show the potential, I’ll use an app that wasn’t made for the Raspberry Pi. I’ll use the sample app
Figure 5 Circuit for the Traffic Lights
is shown in Figure 7.
You can run the program in the exact same way you would on a desktop.
To run this code, you must add a ref- erence to the IoT extensions. Right-click in the References node in the Solution Explorer, click on Add References, then go to Extensions and add the Windows IoT Extensions for UWP.
52 msdn magazine
Internet of Things


































































































   56   57   58   59   60