main 让LED亮起来! · OpenMV中文入门教程

您所在的位置:网站首页 感应灯怎么弄让它长久的亮 main 让LED亮起来! · OpenMV中文入门教程

main 让LED亮起来! · OpenMV中文入门教程

2024-07-11 11:02| 来源: 网络整理| 查看: 265

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

本例程为01-Basics-main.py

# Main Module Example # # 当OpenMV摄像头从电脑断开时,它会运行SD卡上的main.py脚本(如果插了内存卡)或你的OpenMV摄像头内部Flash里的main.py脚本。 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) # 切换到使用绿色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)


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3