找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2250|回复: 0
收起左侧

openmv和STM32通信

[复制链接]
ID:875316 发表于 2021-1-17 21:46 | 显示全部楼层 |阅读模式
相信会有小伙伴在STM32和OPENMV的串口通信上存在一些问题

STM32发送数据时,像发东西上串口调试助手那样就OK,OPENMV接收数据时,直接按官方例程写就行。

但STM32接收时,OPENMV发送时,如果像例程那样写就会出现一些问题,
这两份代码能够实现OPENMV和STM32的稳定通信。
  1. # QRCode Example
  2. #
  3. # This example shows the power of the OpenMV Cam to detect QR Codes
  4. # without needing lens correction.

  5. import sensor, image, time, pyb

  6. led3=pyb.LED(3)
  7. led2=pyb.LED(2)
  8. uart=pyb.UART(3,115200,timeout_char = 1000)
  9. sensor.reset()
  10. sensor.set_pixformat(sensor.RGB565)
  11. sensor.set_framesize(sensor.QVGA)
  12. sensor.skip_frames(time = 2000)
  13. sensor.set_auto_gain(False) # must turn this off to prevent image washout...
  14. clock = time.clock()

  15. while(True):
  16.     clock.tick()
  17.     img = sensor.snapshot()
  18.     img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
  19.     for code in img.find_qrcodes():
  20.         img.draw_rectangle(code.rect(), color = (255, 0, 0))
  21.         led3.on()
  22.         if  code[4] == '11':
  23.             uart.write("l")
  24.         if  code[4] == '21':
  25.             uart.write("R")
  26.         time.sleep(150)
  27.         led3.off()
  28.     if  uart.any():
  29.         a = uart.readline().decode().strip()
  30.         if  a == 'OK':
  31.             led2.on()
复制代码


STM32接收

STM32接收

STM32接收

STM32接收

openmv发送

openmv发送
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表