改到50还是不行,不连接电脑,只连接给vin加5v电压,补光板会闪一下,然后就不亮了
。
K
kqip
@kqip
0
声望
3
楼层
137
资料浏览
0
粉丝
0
关注
kqip 发布的帖子
-
RE: 光源拓展版的程序插入到其他程序中,在脱机运行过程中只能闪烁一下是什么原因?
-
RE: 光源拓展版的程序插入到其他程序中,在脱机运行过程中只能闪烁一下是什么原因?
import sensor, image, time,math,lcd,pyb import ustruct from pyb import UART, LED from pyb import Pin, Timer #50kHz pin6 timer2 channel1 light = Timer(2, freq=50000).channel(1, Timer.PWM, pin=Pin("P6")) light.pulse_width_percent(1) # 控制亮度 0~100 LED_R = pyb.LED(1) LED_G = pyb.LED(2) LED_B = pyb.LED(3) LED_R.off() LED_G.off() LED_B.off() lcd.init() red_threshold = (48, 73, 32, 77, -7, 55) green_threshold =(50, 76, -26, -5, -2, 23) blue_threshold = (44, 75, -3, 40, -84, -37) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_hmirror(True) sensor.set_vflip(True) sensor.skip_frames(n=2000) sensor.set_auto_gain(True) sensor.set_auto_whitebal(True) sensor.set_hmirror(False) sensor.set_vflip(False) clock = time.clock() uart = UART(3,115200) uart.init(115200, bits=8, parity=None, stop=1 ) def find_max(blobs): max_size=0 for blob in blobs: if blob.pixels() > max_size: max_blob=blob max_size = blob.pixels() return max_blob def sending_data(color,cx,cy): global uart; data = ustruct.pack("<bbbbbb", 0x2c,0x12,int(color),int(cx),int(cy),0x5b) uart.write(data); for i in data: print("data的内容是: ",hex(i)) while(True): img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0) red_blobs = img.find_blobs([red_threshold], x_stride=160, y_stride=130, pixels_threshold=8000) green_blobs = img.find_blobs([green_threshold], x_stride=135, y_stride=110, pixels_threshold=8000) blue_blobs = img.find_blobs([blue_threshold],x_stride=220, y_stride=150, pixels_threshold=8000 ) if blue_blobs: color_status = ord('B') for r in blue_blobs: sending_data(color_status,r[5],r[6]) elif green_blobs: color_status = ord('G') for y in green_blobs: sending_data(color_status,y[5],y[6]) elif red_blobs: color_status = ord('R') for y in red_blobs: sending_data(color_status,y[5],y[6]) else: color_status = ord('A')