Skip to content

Commit 45113d1

Browse files
committed
【添加】key 示例代码
1 parent 019ec58 commit 45113d1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/w601_iot_board/key.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+
from machine import Pin
12+
13+
PIN_LED_R = 38
14+
PIN_KEY0 = 57
15+
KEY_PRESSED = 0
16+
17+
# create led object from pin PIN_LED_R, Set pin PIN_LED_R to output mode
18+
led = Pin(("led_red", PIN_LED_R), Pin.OUT_PP)
19+
key_0 = Pin(("key_0", PIN_KEY0), Pin.IN, Pin.PULL_UP)
20+
21+
while True:
22+
if key_0.value() == KEY_PRESSED:
23+
led.value(0) # Set led turn on
24+
else:
25+
led.value(1)

0 commit comments

Comments
 (0)