StarFive VisionFive 2 Manual

Using gpio to make an led blink
Hide thumbs Also See for VisionFive 2:

Advertisement

Quick Links

Using VisionFive 2 GPIO to Make An
LED Blink
with Python
Application Note
Version: 1.0
Date: 2022/11/30
Doc ID: VisionFive2-ANEN-002

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Summary of Contents for StarFive VisionFive 2

  • Page 1 Using VisionFive 2 GPIO to Make An LED Blink with Python Application Note Version: 1.0 Date: 2022/11/30 Doc ID: VisionFive2-ANEN-002...
  • 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 2's GPIO pins to make an LED blink. Revision History Table 0-1 Revision History Version Released Revision 2022/11/30 The first official release.
  • Page 4: Table Of Contents

    1.1. 40-Pin Header Definition..............................7 2. Preparation..................................8 2.1. Environment Requirements..............................8 2.2. Preparing Hardware................................8 2.2.1. Hardware Setup............................... 9 2.3. Preparing Software................................10 3. Running Demo Code................................12 4. Demo Source Code................................13 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...........................9 © 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 Breadboard Overview...............................9 Figure 2-2 Connect LED to the 40-Pin Header..........................10 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 7: Introduction

    1. Introduction This application note provides steps to use VisionFive 2's GPIO pins to make an LED blink. 1.1. 40-Pin Header Definition The following figure shows the location of the 40-pin header on VisionFive 2. Figure 1-1 40-Pin Definition 5V Power 3.3V Power...
  • Page 8: Preparation

    Prepare the following hardware items before running the demo code: Table 2-1 Hardware Preparation Type Item Notes General VisionFive 2 single board computer General These items are used for flashing Debian OS into • 32 GB (or more) micro-SD card a micro-SD card. • micro-SD card reader •...
  • Page 9: Hardware Setup

    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 to the blue line of the breadboard. © 2018-2022 StarFive Technology www.starfivetech.com...
  • Page 10: Preparing Software

    Guide. 2. Log into the Debian and make sure VisionFive 2 is connected to the Internet. For detailed instructions, refer to the Using SSH over Ethernet or Using a USB to Serial Converter section in the VisionFive 2 Single Board Computer Quick Start Guide.
  • Page 11 | 2 - Preparation Alternatively, you can execute the following command: sudo python3 setup.py install © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 12: Running Demo Code

    3. Running Demo Code To run the demo code, perform the following on VisionFive 2 Debian: 1. Locate to the directory where the code, led.py, exists: a. Execute the following command to get the directory where VisionFive.gpio exists: pip show VisionFive.gpio Example Result: Location: /usr/local/lib64/python3.9/site-packages...
  • Page 13: Demo Source Code

    #Configure the voltage level of led_pin as high. GPIO.output(led_pin, GPIO.HIGH) time.sleep(delay) #Configure the voltage level of led_pin as low. GPIO.output(led_pin, GPIO.LOW) time.sleep(delay) __name__ == '__main__': try: delay_s = input("Enter delay(seconds): ") delay = float(delay_s) while True: light(delay) finally: GPIO.cleanup() © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...

Table of Contents