导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. k1o5
    3. 楼层
    K
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    k1o5 发布的帖子

    • RE: 串口通信。 用串口助手发送hex和utf8的1 都不行

      好吧。 谢谢

      发布在 OpenMV Cam
      K
      k1o5
    • RE: 串口通信。 用串口助手发送hex和utf8的1 都不行

      是的。 还有接受的数据类型 是什么

      发布在 OpenMV Cam
      K
      k1o5
    • RE: 串口通信。 用串口助手发送hex和utf8的1 都不行

      运行之后 一段时间之后画面就定格了, 用串口助手发送0 和1 都不工作。 openmv也一直在工作

      发布在 OpenMV Cam
      K
      k1o5
    • 串口通信。 用串口助手发送hex和utf8的1 都不行

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

      thresholds = [(-5,50, 20, 80, 0, 60), # generic_red红_thresholds
      (10, 80, -50, -20, 0, 40), # generic_green绿_thresholds
      (15,75, -40, 35, -60, 0)] # generic_blue蓝_thresholds
      uart = UART(3, 9600)

      ledR= pyb.LED(1)
      ledG= pyb.LED(2)
      ledB= pyb.LED(3)
      led= pyb.LED(1) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4.

      def R():
      ledR.on() #亮灯
      time.sleep(1000) #延时150ms
      ledR.off() #暗灯
      time.sleep(500)
      def B():
      ledB.on() #亮灯
      time.sleep(1000) #延时150ms
      ledB.off() #暗灯
      time.sleep(500)
      def G():
      ledG.on() #亮灯
      time.sleep(1000) #延时150ms
      ledG.off() #暗灯
      time.sleep(500)

      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      clock = time.clock()

      def twoley():
      while(True):
      clock.tick()
      img = sensor.snapshot()
      for code in img.find_qrcodes():
      img.draw_rectangle(code.rect(), color =(255,0,0))
      message =code.payload()
      a_er=int(message)
      uart.write(message)
      print(message)
      if a_er==123:
      while(True):
      R()
      G()
      B()
      print(a_er)

              elif a_er==132:
                  while(True):
                      R()
                      B()
                      G()
                      print(a_er)
      
              elif a_er==213:
                  while(True):
                      G()
                      R()
                      B()
                      print(a_er)
              elif a_er==231:
                  while(True):
                      G()
                      B()
                      R()
                      print(a_er)
      
              elif a_er==312:
                  while(True):
                      B()
                      R()
                      G()
                      print(a_er)
              elif a_er==321:
                  while(True):
                      B()
                      G()
                      R()
                      print(a_er)
      

      def yanshe():
      while(True):
      clock.tick()
      img = sensor.snapshot()
      for blob in img.find_blobs([thresholds[0]], pixels_threshold=200, area_threshold=200):
      img.draw_rectangle(blob.rect())
      img.draw_cross(blob.cx(), blob.cy())
      a=blob.cx()
      for blob in img.find_blobs([thresholds[1]], pixels_threshold=200, area_threshold=200):
      img.draw_rectangle(blob.rect())
      img.draw_cross(blob.cx(), blob.cy())
      b=blob.cx()
      for blob in img.find_blobs([thresholds[2]], pixels_threshold=200, area_threshold=200):
      img.draw_rectangle(blob.rect())
      img.draw_cross(blob.cx(), blob.cy())
      c=blob.cx()
      time.sleep(500)
      if a<b :
      if a<c :
      if b<c :
      a_yanse='123'
      else :
      a_yanse='132'
      else :
      a_yanse='312'
      else :
      if b<c :
      if a<c :
      a_yanse='213'
      else :
      a_yanse='231'
      else :
      a_yanse='321'

                  print(a_yanse)
                  uart.write(a_yanse[0])
                  time.sleep(1000)
                  uart.write(a_yanse[1])
                  time.sleep(1000)
                  uart.write(a_yanse[2])
                  time.sleep(1000)
      

      while(True):

        if uart.any():  uart.readchar()
        flag=uart.read()
      

      if flag=='1':
      twoley()

      elif flag=='0':
      yanshe()

      发布在 OpenMV Cam
      K
      k1o5