import sensor, image, time 
import json
from pyb import UART



sensor.reset() # 初始化相机传感器
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(10) # 让新设置受到影响。
sensor.set_auto_whitebal(False) # turn this off.
clock = time.clock() # 跟踪FPS.

uart = UART(3, 9600)

while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot() # Take a picture and return the image.
    img.lens_corr(1.8)
    for code in img.find_qrcodes():
        message = code.payload()
        uart.write(message)
        print(code)