Raspberry Pi B+ special accessories T-shaped GPIO expansion board development board
You can import the RPi.GPIO module with the following code.
import RPi.GPIO as GPIO
Once introduced, you can use functions from the GPIO module. If you want to check whether the module was introduced successfully, you can also write:
try:
import RPi.GPIO as GPIO
except RuntimeError:
print (” Introduce error “)
Pin number
In RPi.GPIO, both GPIO pin numbers on Raspberry PI are supported. The first number is the BOARD number, which corresponds to the physical pin number on the Raspberry PI board. The advantage of using this numbering is that your hardware will always be usable and you won’t have to worry about Raspberry PI versions. So you don’t need to rewrite the connectors or code after the board is upgraded.
The second type of numbering, the BCM rule, is a more low-level way of working that corresponds to the channel numbering in Broadcom’s system-on-chip. When using a pin, you need to look for the corresponding rules between the channel number and the physical pin number. The script file may not be universal for different versions of Raspberry PI.
You can specify a numbering rule with the following code (mandatory) :
GPIO.setmode (GPIO.BOARD)
#O
GPIO.setmode (GPIO.BCM)
The following code returns the numbering rule that was set
mode=GPIO.getmode ()
warning
If RPi.GRIO detects that a pin has been set to a non-default value, you will see a warning message. You can disable warnings with the following code:
GPIO.setwarnings (False)
Reviews
There are no reviews yet.