GPIO Pull up/down Test

This section describes how to use the demo program to test the GPIO pull up and pull down (PUD) function.

Hardware Setup

Make sure pin 31 of the 4--pin header is in a suspended state (not wired).

Run Demo Code

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

  1. Locate the directory where the test code, pud_test.py, exists.

    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/
  2. Under the sample-code directory, execute the following command to run the demo code.

    sudo python  pud_test.py
    Alternatively, you can also run the following command.
    sudo python3  pud_test.py
    The terminal displays the following:
    # python3 pud_test.py
    *----------------------Start testing------------------------------*
    
    Step 1: set input to direction of GPIO pin 31.
    
    Step 2: the default input level is HIGH.
    
    Step 3.1: set PUD_DOWN to input direction of GPIO pin 31.
    
    Step 3.2: the input level with pull_down enabled is LOW.
    
    Step 4.1: set PUD_UP to input direction of GPIO pin 31.
    
    Step 4.2: the input level with pull_up enabled is HIGH.
    
    *---------------------------end test------------------------------*
    Note: For details about the source code, see edge_detection_with_waiting_time.py Source Code.
  3. (Optional) Exit the Python3 Virtual Environment.

    deactivate