forked from sipeed/MaixPy-v1_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_gpio_led.py
39 lines (33 loc) · 1.09 KB
/
demo_gpio_led.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import time
from Maix import GPIO
from fpioa_manager import fm
from board import board_info
# see board/readme.md to config your sipeed's hardware.
print(board_info.LED_R)
print(board_info.LED_G)
print(board_info.LED_B)
fm.register(board_info.LED_R, fm.fpioa.GPIO0, force=True)
fm.register(board_info.LED_G, fm.fpioa.GPIOHS0, force=True)
fm.register(board_info.LED_B, fm.fpioa.GPIO2, force=True)
fm.register(board_info.BOOT_KEY, fm.fpioa.GPIO3, force=True)
led_r = GPIO(GPIO.GPIO0, GPIO.OUT)
led_g = GPIO(GPIO.GPIOHS0, GPIO.OUT)
led_b = GPIO(GPIO.GPIO2, GPIO.OUT)
key_input = GPIO(GPIO.GPIO3, GPIO.IN)
status = 0
for i in range(0, 20):
led_r.value(status)
time.sleep_ms(300)
led_g.value(status)
time.sleep_ms(300)
led_b.value(status)
time.sleep_ms(300)
status = 0 if (status == 1) else 1
time.sleep_ms(300)
print("LED RGB(%d,%d,%d)" % (led_r.value(), led_g.value(), led_b.value()))
time.sleep_ms(100)
print("key_input:", key_input.value())
fm.unregister(board_info.LED_R)
fm.unregister(board_info.LED_G)
fm.unregister(board_info.LED_B)
fm.unregister(board_info.BOOT_KEY)