This example shows how to use the Grove Buzzer v1.2.
A Grover Buzzer, and PYNQ Grove Adapter are required.
To set up the Pynq-Z1 for this notebook, the PYNQ Grove Adapter is connected to PMODB and the Grove Buzzer is connected to G1 on the PYNQ Grove Adapter.
In [1]:
from pynq import Overlay
Overlay("base.bit").download()
In [2]:
from pynq.iop import Grove_Buzzer
from pynq.iop import PMODB
from pynq.iop import PMOD_GROVE_G1
grove_buzzer = Grove_Buzzer(PMODB, PMOD_GROVE_G1)
In [3]:
grove_buzzer.play_melody()
In [4]:
# Play a tone
tone_period = 1200
num_cycles = 500
grove_buzzer.play_tone(tone_period,num_cycles)
In [5]:
from pynq.iop import ARDUINO
from pynq.iop import Arduino_Analog
from pynq.iop import ARDUINO_GROVE_A1
analog1 = Arduino_Analog(ARDUINO, ARDUINO_GROVE_A1)
rounds = 200
for i in range(rounds):
tone_period = int(analog1.read_raw()[0]/5)
num_cycles = 500
grove_buzzer.play_tone(tone_period,50)