震动 =================== .. figure:: /_static/products/ledong-module/static/图片/震动传感器-H.png :width: 55% :align: center 概述 -------------------- 用于检测物体震动,能感应到物体微弱震动后,触发后输出高电平。 技术参数 ------------------- 工作电压: VCC 3.3V -5V 模块尺寸:24*48mm 固定安装:2个兼容塑料积木通孔 数据类型:震动--1 静止--0 引脚定义 ------------------- ===== ======== 引脚 定义 ===== ======== GND 地 VCC 电源 DO 数字输出 NC 空 ===== ======== 示例程序 ------------------- **当震动传感器被触发时,掌控板RGB灯亮。** .. code-block:: python from mpython import * p0 = MPythonPin(0, PinMode.IN) import time def boolean_P0(): return p0.read_digital() == 1 while True: if boolean_P0(): rgb.fill((int(255), int(0), int(0))) rgb.write() time.sleep_ms(1) time.sleep(1) else: rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) .. figure:: /_static/products/ledong-module/static/examples/震动.png :width: 100% :align: center