From the course: Introduction to IoT with .NET Core

Blinky explained

- Welcome back to .NET Core with IoT series. In this video, we're going to walk through the Blinky sample code and understand what's going on. So, I have the Blinky sample from the GitHub repor open over here in Visual Studio Code. At the top you can see it has a using statements for the GPIO library that we will be using to control the LED pin. In the main part of the program, we've created a variable for pin number 17, which as per the breadboard Connections is what the LED is connected to. The next two values, are how many milliseconds we want the LED to be on and off. This creates the blinking effect. The next important line is line number 20, where we create an instance of the GPIO controller. This is what enables us to interact with the pin. So, we open pin number 17, and we make it ready for output mode. This means that we will be sending current to that pin to then trigger the LED connected in the circuit. Next, we have this line, this section over here which basically sets up the command prompt to listen for Ctrl C to end this loop. Until then this is going to continue. Within a while loop which is constantly set to true which means it's going to infinitely keep blinking the LED light, we are basically sending a high and low value for time in milliseconds to turn it off and on. So, if we walk through this code, you will notice that first we open the pin 17 and send pin value high which passes voltage to the LED to turn it on. And we pause the program for light on for one millisecond. Then we send pin value low which reduces the amount of current and closes the circuit and then leave the program to sleep for 200 milliseconds. When this thing runs in loop it creates effect of often on and therefore blinking the LED. That was a quick and simple walkthrough of the LED Blinky code. Join us in the next video where we will do an advanced sample of using a temperature sensor on a Raspberry Pi

Contents