aiy.pins

GPIO pin definitions for the Vision Bonnet and Voice Bonnet, for use with gpiozero APIs.

These APIs are not compatible with the Voice HAT (V1 Voice Kit).

For example, here’s how to create a gpiozero.Servo with PIN_B:

from gpiozero import Servo
from aiy.pins import PIN_B

# Create a servo with the custom values to give the full dynamic range.
tuned_servo = Servo(PIN_B, min_pulse_width=.0005, max_pulse_width=.0019)

Or here’s how to light up LED_1 on the bonnet when you press the button:

from gpiozero import Button
from gpiozero import LED
from aiy.pins import BUTTON_GPIO_PIN
from aiy.pins import LED_1

# Set up a gpiozero LED using the first onboard LED on the vision hat.
led = LED(LED_1)
# Set up a gpiozero Button using the button included with the vision hat.
button = Button(BUTTON_GPIO_PIN)

while True:
    if button.is_pressed:
        led.on()
    else:
        led.off()

For more examples, see src/examples/gpiozero/.

_images/bonnet-pins_2x.png

Figure 1. Pin and LED positions on the Vision and Voice Bonnet.

aiy.pins.PIN_A
aiy.pins.PIN_B
aiy.pins.PIN_C
aiy.pins.PIN_D
aiy.pins.LED_1

Use this with gpiozero.LED to control LED_1 on the Vision/Voice Bonnet.

aiy.pins.LED_2

Use this with gpiozero.LED to control LED_2 on the Vision/Voice Bonnet.

aiy.pins.BUZZER_GPIO_PIN

The pin on the Raspberry Pi where the Vision Kit’s piezo buzzer is connected (BCM 22). This should be used with aiy.toneplayer.TonePlayer.

aiy.pins.BUTTON_GPIO_PIN

The pin on the Raspberry Pi where the Vision/Voice Kit’s button is connected (BCM 23). This should be used with gpiozero.Button.