Advertisement

Quick Links

Using VisionFive GPIO to Make A
Buzzer Beep
with Python
Application Note
Version: 1.0
Date: 2022/06/30
Doc ID: VisionFive-ANEN-007-1.0

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the VisionFive GPIO and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for StarFive VisionFive GPIO

  • Page 1 Using VisionFive GPIO to Make A Buzzer Beep with Python Application Note Version: 1.0 Date: 2022/06/30 Doc ID: VisionFive-ANEN-007-1.0...
  • Page 2 StarFive does not assume any liability rising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation indirect, incidental, special, exemplary, or consequential damages.
  • Page 3 Preface About this guide and technical support information. About this document This application note provides steps to use VisionFive's GPIO pins to make a buzzer beep through an example program with Python. Revision History Table 0-1 Revision History Version Released Revision V1.0 2022-06-30...
  • Page 4: Table Of Contents

    1. Introduction..................................7 1.1. 40-Pin Header Definition..............................7 2. Preparation..................................8 2.1. Preparing Hardware................................8 2.1.1. Hardware Setup............................... 8 2.2. Preparing Software................................9 3. Running Demo Code................................10 4. Demo Source Code................................11 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 5: List Of Tables

    Contents List of Tables Table 0-1 Revision History.................................iii Table 2-1 Hardware Preparation................................8 Table 2-2 Connect LED to the 40-Pin Header...........................8 © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 6: List Of Figures

    Contents List of Figures Figure 1-1 40-Pin Definition................................7 Figure 2-1 Connect Buzzer to the 40-Pin Header..........................9 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 7: Introduction

    This application note provides steps to use VisionFive's GPIO pins to make a buzzer beep through an example program with Python. 1.1. 40-Pin Header Definition The following figure shows the location of the 40-pin header. The VisionFive board is taken as an example: Figure 1-1 40-Pin Definition © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 8: Preparation

    Prepare the following hardware items before running the demo code: Table 2-1 Hardware Preparation Type Item Notes General StarFive single board computer The following boards are applicable: • StarLight • VisionFive General • 16 GB (or more) micro-SD card These items are used for flashing Fedora OS into a micro-SD card.
  • Page 9: Preparing Software

    Tip: The source code can be downloaded from: VisionFive.gpio. sudo yum install python-devel python3-devel sudo python setup.py install Alternatively, you can execute the following command: sudo python3 setup.py install © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 10: Running Demo Code

    If the value is out of the range (200 to 20000 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, 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.
  • Page 11: Demo Source Code

    == 0: pitch = pitch_in_check() #Input value of cycle time (seconds). cycle_in = input("Enter Cycle (seconds): ") cycle = int(cycle_in) #The buzzer beeps with the specified pitch and cycle. loop(pitch, cycle) © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 12 | 4 - Demo Source Code finally: destroy() www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...

Table of Contents