• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 为什么一传输数据就会出错呀?



    • from machine import I2C
      from vl53l1x import VL53L1X
      from pyb import UART
      import time,pyb,sensor,json
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      uart = UART(3, 9600)
      clock = time.clock()
      
      i2c = I2C(2)
      distance = VL53L1X(i2c)
      led1 = pyb.LED(1)
      led2 = pyb.LED(2)
      led3 = pyb.LED(3)
      clock = time.clock()
      
      while True:
          time.sleep_ms(50)
          dis=distance.read()
          if 610<dis<640:
              data="0"
              data_out = json.dumps(set(data))
              uart.write(data_out +'\n')
              print('you send:',data_out)
          clock.tick()
          img = sensor.snapshot()
          for r in img.find_rects(threshold = 25000):
              img.draw_rectangle(r.rect(), color = (255, 0, 0))
              for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
              if r.w()>r.h():
                  if 470<dis<490:
        
                      data="1"
                      data_out = json.dumps(set(data))
                      uart.write(data_out +'\n')
                      print('you send:',data_out)
                  elif 320<dis<355:
                      data="2"
                      data_out = json.dumps(set(data))
                      uart.write(data_out +'\n')
                      print('you send:',data_out)
              elif r.w()<r.h():
                  if 470<dis<490:
                      data="3"
                      data_out = json.dumps(set(data))
                      uart.write(data_out +'\n')
                      print('you send:',data_out)
                  elif 320<dis<355:
                      data="4"
                      data_out = json.dumps(set(data))
                      uart.write(data_out +'\n')
                      print('you send:',data_out)
      
      
      #include <SoftwareSerial.h>
      SoftwareSerial softSerial(10, 11); // RX, TX
      void setup() 
      {
        softSerial.begin(9600);
        Serial.begin(9600);
      }
      void loop() 
      {
        if(softSerial.available())
       {
          String s = detectString();
           Openmv(s);
        }
      }
      String detectString()
      {
        while(softSerial.read() != '{');
        return(softSerial.readStringUntil('}'));
      }
      void Openmv(String s)
      {
          if(s[1]=='0')
           {
           Serial.print('0');
           Serial.print('\n');
           }
          if(s[1]=='1')
           {      
           Serial.print('1');
           Serial.print('\n');
           }
          if(s[1]=='2')
           {     
           Serial.print('2');
           Serial.print('\n');
           }
           if(s[1]=='3')
           {      
           Serial.print('3');
           Serial.print('\n');
           }
           if(s[1]=='4')
           {      
           Serial.print('4');
           Serial.print('\n');
           }
      }
      


    • 0_1657534539347_4480c644-2990-4647-984c-e7c5b3707cd3-image.png



    • This post is deleted!


    • https://singtown.com/learn/50539/

      先按照视频步骤测试测距扩展板