找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 3111|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

openmv和STM32通信

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
相信會(huì)有小伙伴在STM32和OPENMV的串口通信上存在一些問(wèn)題

STM32發(fā)送數(shù)據(jù)時(shí),像發(fā)東西上串口調(diào)試助手那樣就OK,OPENMV接收數(shù)據(jù)時(shí),直接按官方例程寫(xiě)就行。

但STM32接收時(shí),OPENMV發(fā)送時(shí),如果像例程那樣寫(xiě)就會(huì)出現(xiàn)一些問(wèn)題,
這兩份代碼能夠?qū)崿F(xiàn)OPENMV和STM32的穩(wěn)定通信。
  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()
復(fù)制代碼


51hei圖片_3.png (39.71 KB, 下載次數(shù): 96)

STM32接收

STM32接收

51hei圖片1.png (30.17 KB, 下載次數(shù): 110)

STM32接收

STM32接收

51hei圖片2.png (23.68 KB, 下載次數(shù): 85)

openmv發(fā)送

openmv發(fā)送
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏6 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表