| .. | ||
| .vs/config | ||
| Assets | ||
| Properties | ||
| LED.sln | ||
| LEDTest.csproj | ||
| Package.appxmanifest | ||
| project.json | ||
| project.lock.json | ||
| README.md | ||
| StartupTask.cs | ||
LED Fade Sample
This sample will demonstrate how to use the LED Socket Kit with the Rotary Angle Sensor to create a fade effect using Pulse Width Modulation (PWM). This sample is designed to run on a Raspberry Pi 2 running Windows 10 IoT Core. The application is written as a Background Task and will run in Windows 10 IoT Core without any user interface.
Requirements
You must have the following:
- Windows 10
- Visual Studio 2015 Community Edition or better
- Raspberry Pi 2 running Windows 10 IoT Core
- GrovePi+ Starter Kit for Raspberry Pi
Install a Visual Studio 2015
If you don't already have one installed, install Visual Studio 2015. You can use the free Community edition, or any other higher edition. When you are installing Visual Studio, you must do a Custom install and select to install the Universal Windows App Development Tools -> Tools and Windows SDK.
After the installation is complete, install the Windows IoT Core Project Templates from here.
Enable Developer Mode on your Windows 10 Development Device
When you are developing on Windows 10, you choose what tasks you want to enable on the device. This includes any devices - Windows 10 desktops, tablets and phones. You can enable a device for development, or just app side loading. To enable Developer mode on your Windows 10 device:
- Click the Windows icon (typically in the lower-left of the screen, on the left-most side of the toolbar).
- Type Update and select Windows Update settings from the Best match list. This will open the UPDATE & SECURITY settings page.
- Click on For developers in the left sidebar.
- Ensure the Developer mode radio button is selected.
- Save your changes and close the Settings window.
Build the Samples
Download the GrovePi repository to your development PC.
Each sample is its own solution. There are two ways to run the sample projects - within the GrovePi solution, or as individual solutions.
Samples as Part of GrovePi solution (recommended)
When you run the samples as part of the GrovePi solution you know that you are using the very latest build of GrovePi, however; the samples are not part of the GrovePi solution by default - you must add them.
- Open GrovePi\Software\CSharp\GrovePi.sln in Visual Studio
- Right-click on the solution in the Solution Explorer
- Select Add > __ New Solution Folder__
- Name the folder Samples
- Right-click on the solution in the Solution Explorer
- Select Add > __ Existing Project__
- Find the LED.csproj file - select it and click Open
This will add the LED project to you new Samples directory.
In the LED project you need to update the reference to GrovePi.
- In Solution Explorer expand the LED project and the References node.
- Right-click on the GrovePi reference and click _Remove
- Right-click on the References node and choose Add Reference
- Expand the Projects node
- Select (by checking the check box) the GrovePi project.
- Click OK
The project should now have all the updated references you need.
Samples as Independent Solutions
When you run the sampels as independent solutions, you need to ensure you are referencing a current version of the GrovePi assembly (likely more current than the one available as a NuGet package).
The following steps assume you have already opened GrovePi\Software\CSharp\GrovePi.sln in Visual Studio and built the solution. To build the solution, open GrovePi.sln, and click on press CTRL + SHIFT + B. Then close GrovePi.sln.
After building the GrovePi solution:
- Open GrovePi\Software\CSharp\Samples\LED.sln in Visual Studio.
- In Solution Explorer expand the LED project and the References node.
- Right-click on the GrovePi reference and click _Remove.
- Right-click on "References" and click "Add Reference".
- Select the Browse tab and click the Browse button.
- Browse to GrovePi\Software\CSharp\GrovePi\bin\ARM\Debug and select the GrovePi.dll file
- Click OK
The project should now have all the updated references you need.
Setup the Hardware
For this sample, connect the following:
- LED Socket Kit (Blue color) to D5 (Digital Pin 5)
- LED Socket Kit (Red color) to D6 (Digital Pin 6)
- LED Socket Kit (White color) to D7 (Digital Pin 7)
Run the Sample
To run the sample...
- Right-click on the LED project in the Solution Explorer
- Select Set as Startup Project
- Right-click on the Properties node under LED and select Open
- Select the Debug tab
- Select Remote Machine in the Target device field
- In the Remote Machine field, Type in the name or IP Address of your Windows 10 IoT Core Raspberry Pi
- Press Ctrl + S (this file will not be saved automatically, you must save it manually).
- Press F5 to launch the debugger (it will take a minute or two to deploy your app onto the Raspberry Pi).