openmv/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/led_control.py
iabdalkader 98a29e0870 scripts/examples: Update examples.
- Add examples index.
- Remove RP2040's Bluetooth examples.
- Resort examples.
2023-10-29 21:21:55 +01:00

35 lines
700 B
Python

# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# LED Control Example
#
# This example shows how to control the RGB LED.
import time
from pyb import LED
red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
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()
while True:
for i in range(16):
led_control(i)
time.sleep_ms(500)