序言:openmv上的官网,对于新手来说只是用来大概了解一下openmv到底可以干嘛。如果要具体要用的话,就的去/example/01-Basics/ ,这个网址来看看具体是咋用的。安装下载openmv IDE官网就有教程,我就不废话少说了。
*openmv IDE的使用技巧:看懂英文,别废话,上实例。去:文件--->实例。里面就有很多的例程,把openmv用USB连接上电脑之后,直接烧代码。openmv IDE比较坑的一个点,就是不能先在烧写之前编译一下,看看有没有错误,有错误的话,就可以及时改正,对不对?但是他却不走寻常路,得要烧写进行之后,才可以知道自己写的是否正确,是不是很坑!
1.点亮一盏灯!
import time
from pyb import LED
red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_led = LED(4)
while(True):
red_led.on()
#如果你要点亮不同颜色的灯的上,按照上一行的代码,改一灯颜色的名称就可以了。
2.进行循环点灯
# Main Module Example
#
# When your OpenMV Cam is disconnected from your computer it will either run the
# script on the SD card (if attached) or the script on
# your OpenMV Cam's internal flash drive.
import time, pyb
#将蓝灯赋值给变量led
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 ()):
() #亮灯
(150) #延时150ms
() #暗灯
(100)
()
(150)
()
(600)
#变量led此时代表绿灯
led = (2) # Switch to using the green LED.
#如果openmv已连接到电脑
while(()):
()
(150)
()
(100)
()
(150)
()
(600)
3.呼吸灯
(1).没有加入PWM的呼吸灯,可能会有一些效果不太好的问题。
from pyb import LED
import time
led =LED(1)
while(True):
for i in range(1,300):
for j in range(i,300):
()
(1)
()
(1)
for i in range(-300,0):
for j in range(0,i+300):
()
(1)
()
(1)
(2)。下期,下期会有更新,使用定时器的呼吸灯哦!