Run RPi Demo

This section describes how to run RPi demo on VisionFive 2 or VisionFive 2 Lite to make an LED blink at custom interval or at PWM frequency.

Hardware Setup

Perform the following to connect the LED to the 40-pin GPIO Header:

  1. Connect GPIO36 pin of VisionFive 2 or VisionFive 2 Lite to the red line of the breadboard.
  2. Set up the resistor as shown in the following figure.
  3. Connect the longer leg of the LED to the red line of the breadboard.
  4. Connect the shorter leg of the LED to the blue line of the breadboard.
  5. Connect the GND pin of VisionFive 2 or VisionFive 2 Lite to the blue line of the breadboard.
Figure 1. Connect LED, resistor to the 40-Pin Header
LED 40-Pin GPIO Header
Pin Number Pin Name
Positive 36 GPIO36
Negative 34 GND

Run Demo Code

Perform the following steps on Debian of VisionFive 2 or VisionFive 2 Lite.

  1. Replace the import RPi.GPIO as GPIO command with import VisionFive.gpio as GPIO in the RPi Python demo.

  2. Locate the directory where the test code exists.
    • For LED blink at custom interval, the test code is in #GPIO_basic#_run_on_VisionFive.py
    • For LED blink at PWM frequency, the test code is in RPi_demo_#PWM#_run_on_VisionFive.py
    1. Source into the Python3 Virtual Environment.

      source ./myvenv/bin/activate
    2. Install the dependency.
      python3 -m pip install pillow
    3. Get the directory where VisionFive.gpio exists.

      python3 -m pip show VisionFive.gpio
      Note: The output depends on how the application is installed.
    4. Enter the VisionFive.gpio directory.

      cd <VisionFive.gpio directory>
    5. Enter the sample-code directory.

      cd ./VisionFive/sample-code/
  3. Under the sample-code directory, execute the following command to run the demo code.
    • For LED blink at custom interval, run
      sudo python  #GPIO_basic#_run_on_VisionFive.py
    • For LED blink at PWM frequency, run
      sudo python  RPi_demo_#PWM#_run_on_VisionFive.py
    Alternatively, you can also run one of the following commands.
    sudo python3  #GPIO_basic#_run_on_VisionFive.py
    sudo python3  RPi_demo_#PWM#_run_on_VisionFive.py
    Note: For details about the source code, see RPi_demo Source Code.
  4. (Optional) Exit the Python3 Virtual Environment.

    deactivate