Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to execute RPi.GPIO by Python3.7 in Centos7

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to implement RPi.GPIO in Python3.7 in Centos7, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

1. Introduction of GPIO

As indicated by the arrow in the picture, the welding pin is square, indicating that it is physical pin 1.

Second, test whether the hardware connection is possible.

Physical pin 1 is 3.3v voltage (hot wire), 39 good pin is GND (zero wire), connecting resistor and diode, should be always bright, as shown below:

In the picture: three resistors, each 100 ohms, 300 ohms in series. Light emitting diodes can be divided into positive and negative poles, with long feet as positive poles and broken feet as negative electrodes.

Third, software testing (if RPi.GPIO has been installed) 1. The hardware connection diagram is as follows: pin 39 and pin 7 (in the same column as good 1, row 4)

two。 Software control:

Execute the following command:

Sudo / usr/local/python371/bin/ipython

Enter the following code:

Import RPi.GPIO as GPIOGPIO.setwarnings (False) GPIO.setmode (GPIO.BCM) GPIO.setup (4mGIO. Out) GPIO.output (4MGIO. High) # GPIO.output (4MGIO. Low) # # finally, drop the voltage by 3. The effect picture is as follows:

Fourth, the problems encountered:

If you do not use sudo or use root users to execute, an error will be reported as follows:

In [4]: GPIO.setup (4) GPIO.OUT)- -RuntimeError Traceback (most recent call last) RuntimeError: No access to / dev/mem. Try running as root! The above is all the contents of the article "how Python3.7 executes RPi.GPIO in Centos7". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report