Blink - Controlling an LED
Let’s write our first program to toggle an LED connected with GPIO pin on our virtual target. First, we need to create a file named blink.py
. Right-click on the file explorer tab and select New File
from the menu; a new prompt will open: name it blink.py
and click OK. The file will be created. Alternatively, we can use the terminal.
Now open the empty blink.py file, paste the following code and save it.
blink.py
Now the program is ready and we just need to run it. Go to the terminal and write:
The program will run in a loop and toggle the LED on Pin number 9.
To stop the program press Ctrl+C.
Congratulations! We now know how to control the GPIO pins.
Last updated