导航

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

    1sy4

    @1sy4

    0
    声望
    1
    楼层
    378
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    1sy4 关注

    1sy4 发布的帖子

    • 为什么openmv串口发送给51单片机数据点灯也点不亮

      有人能帮忙看下么

      THRESHOLD = ((24, 97, -25, 100, -128, 127)) # Grayscale threshold for dark things...
      import sensor, image, time
      from pyb import LED
      from pid import PID
      from pyb import UART
      rho_pid = PID(p=0.4, i=0)
      theta_pid = PID(p=0.08, i=0)
      uart = UART(3, 9600)
      
      LED(1).on()
      LED(2).on()
      LED(3).on()
      
      sensor.reset()
      sensor.set_vflip(True)
      sensor.set_hmirror(True)
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
      #sensor.set_windowing([0,20,80,40])
      sensor.skip_frames(time = 2000)     # WARNING: If you use QQVGA it may take seconds
      clock = time.clock()                # to process a frame sometimes.
      
      while(True):
          clock.tick()
          img = sensor.snapshot().binary([THRESHOLD])
          line = img.get_regression([(100,100,0,0,0,0)], robust = True)#返回一条直线对象
          if (line):
              rho_err = abs(line.rho())-img.width()/2     #直线左右偏移距离,需要调整到视野中央
              if line.theta()>90:
                  theta_err = line.theta()-180            #与y轴平行的方向,即0°
              else:
                  theta_err = line.theta()
              print(theta_err)
              #FH = bytearray([0xb3,0xb3])
              #uart.write(FH)
              uart.write((str(theta_err)))
            
         
      
      

      下面是51单片机的接受代码

      #include "reg52.h"
      typedef unsigned int u16;
      typedef unsigned char u8;
      static u8 Temp;  					//定义临时变量
      static u16 a; 
      sbit led1=P2^0;
      sbit led2=P2^1;
      sbit led3=P2^2;
      
      void UsartInit()
      {
      	TMOD=0X20;
      	SCON=0X50;
      	TH1=0XFD;
      	TL1=TH1;
      	PCON=0X00;
      	TR1=1;	
      	ES=1;
      	EA=1;
      }						   
      void main()
      {
      	UsartInit();
      	while(1)
      	{
      			 	
      	}
      }
      /*------------------------------------------------
                          发送一个字节
      ------------------------------------------------*/
      void SendByte(unsigned char dat)
      {
       SBUF = dat;
       while(!TI);
            TI = 0;
      }
      /*------------------------------------------------
                          发送一个字符串
      ------------------------------------------------*/
      void SendStr(unsigned char *s)
      {
       while(*s!='\0')// \0 表示字符串结束标志,通过检测是否字符串末尾
        {
        SendByte(*s);
        s++;
        }
      }
      
      void Usart() interrupt 4
      {   
      	if(RI)                        //判断是接收中断产生
      	{	
      		RI=0;                      //标志位清零
      		Temp=SBUF;
      		a=SBUF;                 
      
      		if(-6<a<3)
      			{
      				led2=0;
      			}
      		if(a<=-6)
      			{
      				led1=0;
      				
      			}			  
      		else
      			{
      				led3=0;						
      			}
      	
      			     	
      	}
      	else
      	{
      		TI=0;
      	}
      }
      
      
      
      发布在 OpenMV Cam
      1
      1sy4