例程讲解-01-main.py让LED亮起来!

本例程为01-Basics-main.py


# Main Module Example
#
# When your OpenMV Cam is disconnected from your computer it will either run the
# main.py script on the SD card (if attached) or the main.py script on
# your OpenMV Cam's internal flash drive.

import time, pyb

#将蓝灯赋值给变量led
led = pyb.LED(3) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4.
usb = pyb.USB_VCP() # This is a serial port object that allows you to
# communciate with your computer. While it is not open the code below runs.

#如果openmv未连接到电脑,蓝灯亮150ms,延时100ms,亮150ms,延时600ms,循环。
while(not usb.isconnected()):
    led.on()            #亮灯    
    time.sleep_ms(150)     #延时150ms    
    led.off()           #暗灯    
    time.sleep_ms(100)
    led.on()
    time.sleep_ms(150)
    led.off()
    time.sleep_ms(600)

#变量led此时代表绿灯
led = pyb.LED(2) # Switch to using the green LED.

#如果openmv已连接到电脑
while(usb.isconnected()):
    led.on()
    time.sleep_ms(150)
    led.off()
    time.sleep_ms(100)
    led.on()
    time.sleep_ms(150)
    led.off()
    time.sleep_ms(600)

results matching ""

    No results matching ""