Example: 50-OpenMV-Boards/50-STM32-Boards/50-Board-Control/led_control.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# LED 控制示例
#
# 此示例展示了如何控制您的OpenMV Cam内置LED。 Use your
# smart phone's camera to see the IR LEDs.

import time
from pyb import LED

red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_led = LED(4)


def led_control(x):
    if (x & 1) == 0:
        red_led.off()
    elif (x & 1) == 1:
        red_led.on()
    if (x & 2) == 0:
        green_led.off()
    elif (x & 2) == 2:
        green_led.on()
    if (x & 4) == 0:
        blue_led.off()
    elif (x & 4) == 4:
        blue_led.on()
    if (x & 8) == 0:
        ir_led.off()
    elif (x & 8) == 8:
        ir_led.on()


while True:
    for i in range(16):
        led_control(i)
        time.sleep_ms(500)

results matching ""

    No results matching ""