Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-01 23:36:21 10月01日 Update

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!

Tags: Articles content physics voltage resistors hardware software pictures tests three not much diodes codes premises light emitting tubes commands most reference effects effect drawings Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS MariaDB OPPO Reno Shulou Technology