grovepi/Software/CSharp/Samples/Example-LED
2025-03-21 16:04:17 +01:00
..
.vs/config first commit 2025-03-21 16:04:17 +01:00
Assets first commit 2025-03-21 16:04:17 +01:00
Properties first commit 2025-03-21 16:04:17 +01:00
LED.sln first commit 2025-03-21 16:04:17 +01:00
LEDTest.csproj first commit 2025-03-21 16:04:17 +01:00
Package.appxmanifest first commit 2025-03-21 16:04:17 +01:00
project.json first commit 2025-03-21 16:04:17 +01:00
project.lock.json first commit 2025-03-21 16:04:17 +01:00
README.md first commit 2025-03-21 16:04:17 +01:00
StartupTask.cs first commit 2025-03-21 16:04:17 +01:00

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:

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:

  1. Click the Windows icon (typically in the lower-left of the screen, on the left-most side of the toolbar).
  2. Type Update and select Windows Update settings from the Best match list. This will open the UPDATE & SECURITY settings page.
  3. Click on For developers in the left sidebar.
  4. Ensure the Developer mode radio button is selected.
  5. 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.

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.

  1. Open GrovePi\Software\CSharp\GrovePi.sln in Visual Studio
  2. Right-click on the solution in the Solution Explorer
  3. Select Add > __ New Solution Folder__
  4. Name the folder Samples
  5. Right-click on the solution in the Solution Explorer
  6. Select Add > __ Existing Project__
  7. 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.

  1. In Solution Explorer expand the LED project and the References node.
  2. Right-click on the GrovePi reference and click _Remove
  3. Right-click on the References node and choose Add Reference
  4. Expand the Projects node
  5. Select (by checking the check box) the GrovePi project.
  6. 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:

  1. Open GrovePi\Software\CSharp\Samples\LED.sln in Visual Studio.
  2. In Solution Explorer expand the LED project and the References node.
  3. Right-click on the GrovePi reference and click _Remove.
  4. Right-click on "References" and click "Add Reference".
  5. Select the Browse tab and click the Browse button.
  6. Browse to GrovePi\Software\CSharp\GrovePi\bin\ARM\Debug and select the GrovePi.dll file
  7. Click OK

The project should now have all the updated references you need.

Setup the Hardware

For this sample, connect the following:

  1. LED Socket Kit (Blue color) to D5 (Digital Pin 5)
  2. LED Socket Kit (Red color) to D6 (Digital Pin 6)
  3. LED Socket Kit (White color) to D7 (Digital Pin 7)

Run the Sample

To run the sample...

  1. Right-click on the LED project in the Solution Explorer
  2. Select Set as Startup Project
  3. Right-click on the Properties node under LED and select Open
  4. Select the Debug tab
  5. Select Remote Machine in the Target device field
  6. In the Remote Machine field, Type in the name or IP Address of your Windows 10 IoT Core Raspberry Pi
  7. Press Ctrl + S (this file will not be saved automatically, you must save it manually).
  8. Press F5 to launch the debugger (it will take a minute or two to deploy your app onto the Raspberry Pi).