This example shows how to use the Grove Buzzer v1.2.
A Grover Buzzer, and PYNQ Grove Adapter are required.
To set up the board 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.overlays.base import BaseOverlay
base = BaseOverlay("base.bit")
In [2]:
from pynq.lib.pmod import Grove_Buzzer
from pynq.lib.pmod import PMOD_GROVE_G1
grove_buzzer = Grove_Buzzer(base.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.lib.arduino import Arduino_Analog
from pynq.lib.arduino import ARDUINO_GROVE_A1
analog1 = Arduino_Analog(base.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)