Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
gaubuali
Published © GPL3+

Windows IoT Core ready by LED blinky

If the Raspberry Pi application does not require a screen or LCD, LED blinking will tell you when system is started up and the OS is ready.

BeginnerShowcase (no instructions)1 hour1,612
Windows IoT Core ready by LED blinky

Things used in this project

Story

Read more

Code

Run

C#
public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
            await RunAsyncBlinky();
            deferral.Complete();
        }

        private Task RunAsyncBlinky()
        {
            GpioPin pin;
            const int LED_PIN = 5;
            GpioPinValue pinValue;
            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                pin = null;
                return Task.CompletedTask;
            }

            pin = gpio.OpenPin(LED_PIN);
            pinValue = GpioPinValue.High;
            pin.Write(pinValue);
            pin.SetDriveMode(GpioPinDriveMode.Output);

            while (true)
            {
                pin.Write(GpioPinValue.High);
                Task.Delay(-1).Wait(200);
                
                pin.Write(GpioPinValue.Low);
                Task.Delay(-1).Wait(200);
            }
        }

Credits

gaubuali
6 projects • 15 followers
Contact

Comments

Please log in or sign up to comment.