Les astuces du GPIO

Références :

Résumé :

#set up GPIO using BCM numbering :

GPIO.setmode(GPIO.BCM)

# This will enable a pull-down resistor on pin 23, and a pull-up resistor on pin 24.

# Now, let’s check to see if we can read them. The Pi is looking for a high voltage on Pin 23 and a low voltage on Pin 24.

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# A rising-edge is defined by the time the pin changes from low to high, but it only detects the change.

# Similarly, the falling-edge is the moment the pin changes from high to low.

GPIO.wait_for_edge(23, GPIO.RISING)
GPIO.wait_for_edge(24, GPIO.FALLING)

callback function. This is a function that is attached to a specific GPIO pin and run whenever that edge is detected.

The callback function is in a separate thread.

GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300)

Events let you remove them from a pin just as easily as you can add them :

GPIO.remove_event_detect(23)

Aussi… À documenter [de (2)]:

if GPIO.RPI_REVISION == 0:
  revision = 'Compute Module'
 elif GPIO.RPI_REVISION == 1:
  revision = 'revision 1'
 elif GPIO.RPI_REVISION == 2:
  revision = 'revision 2'
 elif GPIO.RPI_REVISION == 3:
  revision = 'Model B+'
 else:
  revision = '**undetected**'

Autres options :

GPIO.setup(LOOP_IN, GPIO.IN)
GPIO.setup(LOOP_OUT, GPIO.OUT)

Cette doc doit exister !

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *