Make an LED Blink
This section describes how to use VisionFive 2 or VisionFive 2 Lite's GPIO pins to make an LED blink through an example program with Python.
Hardware Setup
- Connect GPIO50 pin of VisionFive 2 or VisionFive 2 Lite to the red line of the breadboard.
- Set up the resistor as shown in the following figure.
- Connect the longer leg of the LED to the red line of the breadboard.
- Connect the shorter leg of the LED to the blue line of the breadboard.
- Connect the GND pin of VisionFive 2 or VisionFive 2 Lite to the blue line of the breadboard.
| LED | 40-Pin GPIO Header | |
|---|---|---|
| Pin Number | Pin Name | |
| Positive | 22 | GPIO50 |
| Negative | 6 | GND |
Run Demo Code
Perform the following steps on Debian of VisionFive 2 or VisionFive 2 Lite.
-
Locate the directory where the test code,
led.py, exists.-
Source into the PYthon3 Virtual Environment.
source ./myvenv/bin/activate -
Install the dependency.
python3 -m pip install pillow -
Get the directory where
VisionFive.gpioexists.python3 -m pip show VisionFive.gpioNote: The output depends on how the application is installed. -
Enter the
VisionFive.gpiodirectory.cd <VisionFive.gpiodirectory> -
Enter the
sample-codedirectory.cd ./VisionFive/sample-code/
-
Under the
sample-codedirectory, execute the following command to run the demo code.
Alternatively, you can also run the following command.sudo python led.pysudo python3 led.pyNote: For details about the source code, see led.py Source Code.-
Enter the time interval (in seconds) for the LED on-off cycle. For example, if you enter 2, the LED turns on and off at a 2-second interval.
-
(Optional) Exit the Python3 Virtual Environment.
deactivate