Running Demo Code

To run the demo code, perform the following on VisionFive 2 Debian:

  1. Locate to the directory where the code, buzzer.py, exists:
    1. Execute the following command to get the directory where VisionFive.gpio exists:
      pip show VisionFive.gpio
      Result:
      Location: /usr/local/lib64/python3.9/site-packages
      Note:

      The actual output depends on how the application is installed.

    2. Execute the following to enter the directory, for example, /usr/local/lib64/python3.9/site-packages as indicated in the previous step output:
      cd /usr/local/lib64/python3.9/site-packages
    3. Execute the following command to enter the sample-code directory:
      cd ./VisionFive/sample-code/
  2. Under the sample-code directory, execute the following command:
    sudo python buzzer.py

    Alternatively, you can execute the following command:

    sudo python3 buzzer.py
  3. Enter the values as prompted to configure the pitch and the lasting time of the beeps as prompted:
    • Enter Pitch (200 to 20000): The frequency (Range: 200 to 20,000) of the buzzer. Unit: Hz. For example, 400.
      Note: If the value is out of the range (200 to 20,000 Hz) , a warning message will display, and you need to re-enter the pitch value.
    • Enter Cycle (seconds): The time in seconds when the buzzer keeps beeping. For example, 100.

    Example:
    [riscv@fedora-starfive sample-code]$ sudo python3 buzzer.py
    Enter Pitch (200 to 20000): 400
    Enter Cycle (seconds): 100
    
    Result:

    The buzzer keeps beeping for 100 seconds at 400 Hz.