Skip to content

Commit bc6286c

Browse files
committed
【添加】蜂鸣器例程
1 parent d7199bd commit bc6286c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/w601_iot_board/beeper.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Copyright (c) 2006-2019, RT-Thread Development Team
3+
#
4+
# SPDX-License-Identifier: MIT License
5+
#
6+
# Change Logs:
7+
# Date Author Notes
8+
# 2019-06-13 SummerGift first version
9+
#
10+
11+
import utime as time
12+
from machine import Pin
13+
14+
PIN_BEEPER = 37
15+
16+
beeper = Pin(("beep", PIN_BEEPER), Pin.OUT_PP) # create beeper object from pin PIN_BEEPER, Set pin PIN_BEEPER to output mode
17+
18+
beeper.value(1) # trun the buzzer on
19+
time.sleep(0.5)
20+
beeper.value(0) # trun the buzzer off
21+
time.sleep(0.5)
22+
beeper.value(1)
23+
time.sleep(0.5)
24+
beeper.value(0)
25+
time.sleep(0.5)

0 commit comments

Comments
 (0)