Simple test

Ensure your device works with this simple test.

examples/async_buzzer_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2# SPDX-FileCopyrightText: Copyright (c) 2023 Phil Underwood for Underwood Underground
 3#
 4# SPDX-License-Identifier: Unlicense
 5import asyncio
 6import board
 7import pwmio
 8
 9from async_buzzer import Buzzer
10
11tune = [
12    ("E5", 500),
13    ("G5", 500),
14    ("A5", 1000),
15    ("E5", 500),
16    ("G5", 500),
17    ("B5", 250),
18    ("A5", 750),
19    ("E5", 500),
20    ("G5", 500),
21    ("A5", 1000),
22    ("G5", 500),
23    ("E5", 1500),
24]
25
26pwm = pwmio.PWMOut(board.D10, variable_frequency=True)
27buzzer = Buzzer(pwm)
28
29
30async def main():
31    buzzer.play(tune, wait=False)
32    for i in range(5):
33        print(i)
34        await asyncio.sleep(1)
35    await buzzer.wait()
36
37
38asyncio.run(main())