GrovePi Windows IoT: LED Blink

This tutorial shows the simplest thing that you can do with the GrovePi: Blink a LED.

Introduction to GrovePi with Windows IOT: LED Blink Tutorial

This tutorial shows the simplest thing that you can do with the GrovePi: Blink a LED. This is a great first project to learn how to connect hardware to the Raspberry Pi. The blinking LED is the hardware version of the software world’s “Hello World” program. Once mastered, you can move on to more complicated projects like connecting a display to the Raspberry Pi or other sensors.

This example is meant to be your first project with the GrovePi. All the parts used in this project are available in the GrovePi Starter Kit.

Prerequisites

  1. Raspberry Pi running Windows IoT
  2. GrovePi Starter Kit

Hardware for This Tutorial

All of the hardware comes with the GrovePi starter kit. Specifically, for the Raspberry Pi LED Tutorial, you’ll need:

  1. The Raspberry Pi
  2. GrovePi
  3. Grove LED
  4. One Grove Connection wire

Hardware Setup: Connecting the LED to the Raspberry Pi

Software: Running the Program

  1. Download the GrovePi Windows IoT Drivers and open GrovePi.sln
  2. Set “Driver” as your “Startup Project” 
  3. Replace the code found in “SampleDriver.CS” with the code listed below
  4. Deploy to your device and watch the LED blink. (Refer to this link If you have not previously setup visual studio to deploy to your Raspberry Pi)

SampleDriver.cs :

  1. using System.Threading.Tasks;
  2. using Windows.ApplicationModel.Background;
  3. using GrovePi;
  4. using GrovePi.Sensors;
  5. namespace Driver
  6. {
  7.    public sealed class SimpleDriver : IBackgroundTask
  8.    {
  9.       private readonly IBuildGroveDevices _deviceFactory = DeviceFactory.Build;
  10.       public void Run(IBackgroundTaskInstance taskInstance)
  11.       {
  12.          var led = _deviceFactory.Led(Pin.DigitalPin4);
  13.          while (true)
  14.          {
  15.             led.ChangeState(SensorStatus.On);
  16.             Task.Delay(500).Wait();
  17.             led.ChangeState(SensorStatus.Off);
  18.             Task.Delay(500).Wait();
  19.          }
  20.       }
  21.    }
  22. }

Schematics

Source: GrovePi Windows IoT: LED Blink


About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top