蜂鸣器

../../../../_images/%E8%9C%82%E9%B8%A3%E5%99%A8-H.png

概述

有源蜂鸣器,高电平工作,低电平停止。

技术参数

工作电压: VCC 3.3V -5V

模块尺寸:24*48mm

固定安装:2个兼容塑料积木通孔

控制方式:数字输入

引脚定义

引脚

定义

GND

地

VCC

电源

DI

数字输入

NC

空

示例程序

按A键蜂鸣器发出声音,按B键停止。

from mpython import *

p0 = MPythonPin(0, PinMode.OUT)

def on_button_a_pressed(_):
    p0.write_digital(1)

button_a.event_pressed = on_button_a_pressed

def on_button_b_pressed(_):
    p0.write_digital(0)

button_b.event_pressed = on_button_b_pressed
../../../../_images/%E8%9C%82%E9%B8%A3%E5%99%A8.png