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



    • 如何定时500毫秒串口发送数据,Timer类给的示例运行不成功



    • import sensor, image
      import pyb
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      
      last_time = pyb.millis()
      
      while(True):
          img = sensor.snapshot()
          if pyb.millis() - last_time > 500:
              last_time = pyb.millis()
              print('send')
              
      


    • 你好,试了一下这个定时500ms会因程序周期变化而变化,中断定时给其它单片机通讯改怎么写呢?谢谢!!!



    • import time
      from pyb import UART
      from pyb import Timer
      
      uart = UART(3, 19200)
      data_bytes = b'123456'
      # we will receive the timer object when being called
      # Note: functions that allocate memory are Not allowed in callbacks
      def tick(timer):
          global data_bytes
          global uart
          print(data_bytes)
          uart.write(data_bytes)
      
      
      tim = Timer(2, freq=2)  # create a timer object using timer 2 - trigger at 1Hz
      tim.callback(tick)  # set the callback to our tick function
      
      while True:
          data_bytes = b'123456'
          time.sleep_ms(1000)
          data_bytes = b'654321'
          time.sleep_ms(1000)