找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1874|回复: 2
打印 上一主题 下一主题
收起左侧

四足爬坡机器人单片机程序

[复制链接]
跳转到指定楼层
楼主
ID:481221 发表于 2019-2-26 21:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #include<reg60s2.h>//芯片头文件  寄存器已经修改
  2. #include<math.h>
  3. #include<delay.h>  //延时程序  通过示波器测试
  4. #define uchar unsigned char            
  5. #define uint  unsigned int
  6. sbit KG=P1^7;                 //开关的位置
  7. uchar position[8];//用于记录8个舵机的位置
  8. uchar pick_up[8];           //kouchu[8];各个io口轮流输出是屏蔽其它位
  9. uchar arr[8];               //提供排序空间 paixu_ncha[8]=0;中间过度用      
  10. uchar t0bit=0;                            //定时器0周期相同标志位
  11. uchar N;
  12. void first();
  13. void second();
  14. void three();
  15. //void four();
  16. //关于扫尾值的参数
  17. //uchar zsax=15; //14h,z 平面sa 修正参数                                   p da  z  xiao  
  18. //uchar psax=10; //15h,p 平面sa 修正参数交互2
  19. //uchar zsag=20; //16h,z 平面sa 过渡参数
  20. //uchar psag=20;//17h,p 平面sa 过渡参数
  21. /*************************************************************************************
  22. 函数名称:void low_level_500u
  23. 函数功能:PWM信号低电平时间子程序,控制舵机PWM信号的低电平时间决定舵机转动的速度  积分思想
  24. 输入    :  time
  25. 输出    :无
  26. *************************************************************************************/
  27. void low_level_500u(uint time)
  28. {
  29.   uint i;
  30.   for(i=0;i<time;i++)
  31.   {delay500us(1);}
  32. }
  33. /*************************************************************************************
  34. 函数名称:void t0_init
  35. 函数功能:t0定时器初始化,用于舵机2.5ms定时
  36. 输入    :无
  37. 输出    :无
  38. 备注    :没有开启定时
  39. *************************************************************************************/
  40. void t0_init(void)           //定时器初始化
  41. {                                                                        
  42.   TMOD  = TMOD & 0xf0;        //初始化定时器1的计数方式为方式1     无用
  43.   TMOD  = TMOD | 0x01;

  44.   TH0=0xee;                                  //22.1184MHz,2.5Ms定时ee00
  45.   TL0=0x00;
  46.   ET0=1;                                                
  47.   EA=1;
  48.   t0bit=1;
  49. }
  50. /*************************************************************************************
  51. 函数名称:void low_level_t0
  52. 函数功能:同周期定时器0设置及启动程序,使每变化一个变化量的周期相同         给寄存器填值
  53. 输入    :THTL
  54. 输出    :无
  55. *************************************************************************************/
  56. void low_level_t0(uint THTL)   //定时器调用函数
  57. {
  58.   TH0=THTL>>8;                          //22.1184MHz,2.5Ms定时ee00
  59.   TL0=THTL;
  60.   t0bit=0;
  61.   TR0=1;
  62. }
  63. /*************************************************************************************
  64. 函数名称:void T0_Interrupt(void) interrupt 1
  65. 函数功能:定时器t0中断服务函数函数        中断一次填一次值 标记一次一个2.5ms到了
  66. 输入    :
  67. 输出    :无
  68. *************************************************************************************/
  69. void T0_Interrupt(void) interrupt 1                //定时器中断函数   中断一次填一次值 标记一次一个2.5ms到了
  70. {  
  71.    TH0=0xee;                     //22.1184MHz,2.5Ms定时ee00
  72.    TL0=0x00;
  73.    t0bit=1;
  74. }
  75. /*************************************************************************************
  76. 函数名称:init_cpu
  77. 函数功能:单片机初始化程序
  78. 输入    :无
  79. 输出    :无
  80. *************************************************************************************/
  81. void  init_cpu(void)
  82. {                                                                                          
  83.         t0_init();                                                //定时器0初始化
  84.         delay500us(10);
  85. }

  86. /*************************************************************************************
  87. 函数名称:array()
  88. 函数功能:排序子程序,将各个口的8位根据时间的长短排序 提供arr[i]=arr[i]- arr[i+1]相邻差值
  89. 输入    :无
  90. 输出    :无
  91. *************************************************************************************/
  92. void array()
  93. {
  94.         uchar i=0,j=0,x=0;

  95.         pick_up[0]=0xFE;
  96.     pick_up[1]=0xFD;
  97.     pick_up[2]=0xFB;
  98.     pick_up[3]=0xF7;
  99.     pick_up[4]=0xEF;
  100.     pick_up[5]=0xDF;
  101.     pick_up[6]=0xBF;
  102.     pick_up[7]=0x7F;        //赋值

  103.         //冒泡排序
  104.         for(i=0;i<=7;i++)
  105.         {    for(j=i+1;j<=8;j++)
  106.          {
  107.                          if(arr[i]<arr[j])//交换数据
  108.                         {
  109.                                 x=arr[j];
  110.                                 arr[j]=arr[i];
  111.                                 arr[i]=x;
  112.                                           
  113.                                 x=pick_up[j];
  114.                                 pick_up[j]=pick_up[i];
  115.                 pick_up[i]=x;  
  116.              }
  117.          }
  118.         }        
  119.         for(i=0;i<7;i++)
  120.     {
  121.                 arr[i]= arr[i]- arr[i+1];
  122.     }                 
  123. }
  124. /*************************************************************************************
  125. 函数名称:void PWM_8()
  126. 函数功能:8路舵机输出子程序,实现8路舵机的PWM信号在最短的时间内输出
  127. 输入    :position[i]
  128. 输出    :无
  129. 备注    :P0口
  130. *************************************************************************************/
  131. void PWM_8()
  132. {
  133.         uchar i=0,j;

  134.         for(i=0;i<8;i++)          //取P0口舵机对应的值
  135.         {arr[i]=position[i];}
  136.     array();                 //排序计算   
  137.         low_level_t0(0xee00);          //开启定时器并赋初始值,   22.1184MHz,2.5Ms定时ee00                                                      
  138.     P0=0xff;                  //使口P0全部拉高
  139.     delay500us(1);            //调用延时500us函数
  140.     for(i=0;i<8;i++)          //P0口8路同时输出
  141.     {      
  142.                 for(j=0;j<arr[7-i];j++)          //此时arr为(安位置大小)相邻舵机位置相差值
  143.                 {delay8us(1);}
  144.         P0=P0&pick_up[7-i];                  //此时pick_up为 代表的是那一位为0 逻辑与后拉低
  145.     }
  146.     while(t0bit==0);                             //等待2.5ms应该说是一个周期的到来  可自定义               
  147.         TR0=0;                                                    //关闭定时器0
  148. }
  149. /*************************************************************************************
  150. 函数名称:initial_position();
  151. 函数功能:初始位置子程序,根据各个舵机的不同位置设置初始位置
  152. 输入    :无
  153. 输出    :无
  154. *************************************************************************************/
  155. void initial_position(void)                 
  156. {
  157.         uint i,j,x=0;
  158.         for(i=0;i<30;i++)
  159.         {        x++;

  160. /////初始                                 

  161. //        position[0]=143;          //-后
  162. //        position[1]=92;          //-后
  163. //        position[2]=126;          //-前
  164. //        position[3]=131;      // +后
  165. //        position[4]=128;      //+前
  166. //        position[5]=136;          // -后
  167. //        position[6]=127;    //+后                                                                       
  168. //        position[7]=172;   // -前
  169.         
  170.         
  171.         position[0]=145;          //-后        
  172.         position[1]=100;          //-后
  173.         position[2]=88;          //-前
  174.         position[3]=100;      // +后                     
  175.         position[4]=96;      //+前
  176.         position[5]=169;          // -后
  177.         position[6]=167;    //+后                                                                       
  178.         position[7]=137;   // -前         



  179.                 PWM_8();
  180.                 if(x<10)
  181.         {j=20;j--;
  182.                 low_level_500u(j);
  183.                 }
  184.                 else
  185.         {        j=10;
  186.                     j++;
  187.                    low_level_500u(j);
  188.         }                                       
  189.         }
  190.                }

  191. /*************************************************************************************
  192. 函数名称:main
  193. 函数功能:入口函数
  194. 输入    :无
  195. 输出    :无
  196. *************************************************************************************/
  197. void main(void)
  198. {   
  199.     SP=0x70;     //堆栈指针初始化
  200.         P0M1 = 0x00;//P0 as Digital OUTPUT
  201.         P0M0 = 0x00;   
  202.            
  203.         init_cpu();//初始化cpu  设置定时器

  204.      delay500us(10);
  205.      P0=0xff;
  206.          delay500ms(1);
  207.          initial_position();//初始位置
  208.          delay500ms(1);        
  209.          
  210.                  while(KG)   
  211.         {
  212.                 if(!KG)
  213.                 delay500us(1);            //调用延时500us函数
  214.                 if(!KG)
  215.                 break;
  216.         }                                                                  


  217.                 while(1)
  218.         {
  219.                                 first();
  220. //                        second();        
  221. //                        three();
  222. //                                four();        
  223.                         }   
  224.             while(1);




  225. }









  226. //前进****************************************************************************************************************
  227. //---------------------------------------------  
  228.    void first ()
  229.   {


  230. uint i=0;
  231.                 for(i=0;i<1;i++)
  232.           {

  233.         position[0]=145;          //-后        
  234.         position[1]=95;          //-后
  235.         position[2]=88;          //-前
  236.         position[3]=100;      // +后                     
  237.         position[4]=96;      //+前
  238.         position[5]=169;          // -后
  239.         position[6]=167;    //+后                                                                       
  240.         position[7]=137;   // -前

  241.          PWM_8();
  242.         delay10ms(50);

  243.         }                                                                                                                                                               



  244.                 for(i=0;i<1;i++)
  245.           {

  246.         position[0]=90;          //-后        
  247.         position[1]=95;          //-后
  248.         position[2]=88;          //-前
  249.         position[3]=100;      // +后                     
  250.         position[4]=96;      //+前
  251.         position[5]=169;          // -后
  252.         position[6]=167;    //+后                                                                       
  253.         position[7]=137;   // -前

  254.          PWM_8();
  255.         delay1s(2);

  256.         }

  257.                 for(i=0;i<1;i++)
  258.           {

  259.         position[0]=145;          //-后        
  260.         position[1]=95;          //-后
  261.         position[2]=88;          //-前
  262.         position[3]=100;      // +后                     
  263.         position[4]=96;      //+前
  264.         position[5]=169;          // -后
  265.         position[6]=167;    //+后                                                                       
  266.         position[7]=137;   // -前

  267.          PWM_8();
  268.         delay1s(1);

  269.         }

  270.                 for(i=0;i<1;i++)
  271.           {

  272.         position[0]=145;          //-后        
  273.         position[1]=100;          //-后
  274.         position[2]=88;          //-前
  275.         position[3]=100;      // +后                     
  276.         position[4]=96;      //+前
  277.         position[5]=169;          // -后
  278.         position[6]=167;    //+后                                                                       
  279.         position[7]=137;   // -前

  280.          PWM_8();
  281.         delay1s(1);

  282.         }

  283.                
  284.                                  
  285.         
  286.         
  287.         }                  
  288. //*************************************************************





  289. //----------------------------------------------------------------------------------------------------

  290. //前进****************************************************************************************************************
  291. //
  292. //
  293. //
  294. ////向左****************************************************************************************************************
  295. ////---------------------------------------------  
  296. //   void first ()
  297. //  {
  298. //
  299. //
  300. // uint i=0;
  301. //                for(i=0;i<1;i++)
  302. //          {
  303. //
  304. //        position[0]=106;          //-后        
  305. //        position[1]=67;          //-后
  306. //        position[2]=108;          //-前
  307. //        position[3]=80;      // +后                     
  308. //        position[4]=76;      //+前
  309. //        position[5]=169;          // -后
  310. //        position[6]=167;    //+后                                                                       
  311. //        position[7]=137;   // -前
  312. //
  313. //         PWM_8();
  314. //        delay10ms(50);
  315. //        }                                                                                                                                                               
  316. //
  317. ////*****************************************************
  318. //    for (i=0;i<40;i++)
  319. //        {
  320. //        position[1]+=1;          //-后
  321. //                        if (i>10&&i<38)
  322. //        {
  323. //        position[1]-=1;      //+前
  324. //        }
  325. //
  326. //        position[2]+=1;          //-前
  327. //                        if (i>20)
  328. //        {
  329. //        position[2]-=1;      //+前
  330. //        }            
  331. //        position[3]+=1;      // +后
  332. //                                if (i>20)
  333. //        {
  334. //        position[3]-=1;      //+前
  335. //        }                     
  336. //        position[4]+=1;      //+前
  337. //                if (i>10&&i<38)
  338. //        {
  339. //        position[4]-=1;      //+前
  340. //        }               
  341. //                 PWM_8();                          
  342. //        delay1ms(5);                          
  343. //        
  344. //        }
  345. //
  346. ////**************************************************************************
  347. //
  348. //
  349. //        
  350. //                        for (i=0;i<1;i++)
  351. //                {
  352. //        position[0]=108;          //-后
  353. //        position[1]=84;          //-后
  354. //        position[2]=126;          //-前
  355. //        position[3]=131;      // +后
  356. //        position[4]=125;      //+前
  357. //        position[5]=180;          // -后
  358. //        position[6]=165;    //+后
  359. //        position[7]=137;   // -前
  360. //                        
  361. //                        PWM_8();
  362. //                 delay10ms(5);
  363. //                }
  364. //
  365. //
  366. //                        for (i=0;i<1;i++)
  367. //                {
  368. //        position[0]=108;          //-后
  369. //        position[1]=84;          //-后
  370. //        position[2]=126;          //-前
  371. //        position[3]=131;      // +后
  372. //        position[4]=125;      //+前
  373. //        position[5]=235;          // -后
  374. //        position[6]=165;    //+后
  375. //        position[7]=25;   // -前
  376. //                        
  377. //                        PWM_8();
  378. //                 delay10ms(10);
  379. //                }
  380. //
  381. //                for (i=0;i<1;i++)
  382. //                {
  383. //
  384. //        position[0]=155;          //-后
  385. //        position[1]=84;          //-后
  386. //        position[2]=126;          //-前
  387. //        position[3]=131;      // +后
  388. //        position[4]=125;      //+前
  389. //        position[5]=235;          // -后
  390. //        position[6]=90;    //+后
  391. //        position[7]=25;   // -前               
  392. //                        PWM_8();
  393. //                 delay10ms(10);
  394. //                }
  395. //
  396. //                for (i=0;i<1;i++)
  397. //                {
  398. //
  399. //        position[0]=155;          //-后
  400. //        position[1]=84;          //-后
  401. //        position[2]=126;          //-前
  402. //        position[3]=131;      // +后
  403. //        position[4]=125;      //+前
  404. //        position[5]=235;          // -后
  405. //        position[6]=90;    //+后
  406. //        position[7]=60;   // -前               
  407. //                        PWM_8();
  408. //                 delay10ms(10);
  409. //                }
  410. //
  411. // //**************************************************************
  412. //    for (i=0;i<40;i++)
  413. //        {
  414. //        position[0]+=1;          //-后
  415. //                        if (i>27)
  416. //        {
  417. //        position[0]-=1;      //+前
  418. //        }
  419. //        position[1]+=1;          //-后
  420. //                        if (i>15&&i<32)
  421. //        {
  422. //        position[1]-=1;      //+前
  423. //        }
  424. //        position[2]+=1;          //-前
  425. //        position[3]+=1;      // +后
  426. //        position[4]+=1;      //+前
  427. //        position[5]-=4;          // -后
  428. //                        if (i>35)
  429. //        {
  430. //        position[5]+=4;      //+前           
  431. //        }
  432. //        position[6]-=1;    //+后
  433. //                        if (i>3)
  434. //        {
  435. //        position[6]+=1;      //+前
  436. //        }
  437. //        position[7]+=4;   // -前
  438. //                        if (i>39)
  439. //        {
  440. //        position[7]-=4;      //+前
  441. //        }        
  442. //                 PWM_8();
  443. //        delay1ms(5);
  444. //        
  445. //        }
  446. //
  447. ////**************************************************************
  448. //
  449. // }        
  450. //
  451. //
  452. //
  453. //
  454. //
  455. //
  456. //
  457. //        
  458. //        
  459. //
  460. //
  461. //
  462. // void  second ()
  463. // {
  464. //           uint i=0;
  465. //                for(i=0;i<1;i++)
  466. //          {
  467. //
  468. //        position[0]=163;          //-后
  469. //        position[1]=124;          //-后
  470. //        position[2]=166;          //-前
  471. //        position[3]=171;      // +后
  472. //        position[4]=165;      //+前
  473. //        position[5]=110;          // -后
  474. //        position[6]=107;    //+后                                                                       
  475. //        position[7]=194;   // -前        
  476. //            PWM_8();
  477. //           delay10ms(50);
  478. //           }
  479. //
  480. ////**************************************************************
  481. //    for (i=0;i<40;i++)
  482. //        {
  483. //        position[0]-=1;          //-后
  484. //                                        if (i>20)
  485. //        {
  486. //        position[0]-=1;      //+前
  487. //        }
  488. //        position[5]+=1;          //-前
  489. //                                        if (i>5)
  490. //        {
  491. //        position[5]-=1;      //+前
  492. //        }   
  493. //        position[6]+=1;      // +后
  494. //                                        if (i>20)
  495. //        {
  496. //        position[6]-=1;      //+前
  497. //        }                     
  498. //        position[7]-=1;      //+前
  499. //        if (i>5&&i<40)
  500. //        {
  501. //        position[7]+=1;      //+前
  502. //        }        
  503. //                 PWM_8();
  504. //        delay1ms(5);
  505. //        
  506. //        }
  507. //
  508. ////**************************************************************
  509. //                for (i=0;i<1;i++)
  510. //                {
  511. //        position[0]=143;          //-后
  512. //        position[1]=139;          //-后
  513. //        position[2]=174;          //-前
  514. //        position[3]=177;      // +后
  515. //        position[4]=171;      //+前
  516. //        position[5]=132;          // -后
  517. //        position[6]=127;    //+后
  518. //        position[7]=176;   // -前               
  519. //                        PWM_8();
  520. //                 delay10ms(5);
  521. //                }
  522. //
  523. //                for (i=0;i<1;i++)
  524. //                {
  525. //        position[0]=143;          //-后
  526. //        position[1]=240;          //-后
  527. //        position[2]=174;          //-前
  528. //        position[3]=177;      // +后
  529. //        position[4]=235;      //+前
  530. //        position[5]=132;          // -后
  531. //        position[6]=127;    //+后
  532. //        position[7]=176;   // -前               
  533. //                        PWM_8();
  534. //                 delay10ms(10);
  535. //                }
  536. //
  537. //                for (i=0;i<1;i++)
  538. //                {
  539. //        position[0]=143;          //-后
  540. //        position[1]=240;          //-后
  541. //        position[2]=114;          //-前
  542. //        position[3]=120;      // +后
  543. //        position[4]=235;      //+前
  544. //        position[5]=132;          // -后
  545. //        position[6]=127;    //+后
  546. //        position[7]=176;   // -前
  547. //        PWM_8();
  548. //   delay10ms(10);
  549. //        }
  550. //
  551. //
  552. //                for (i=0;i<1;i++)
  553. //                {
  554. //        position[0]=143;          //-后
  555. //        position[1]=200;          //-后
  556. //        position[2]=114;          //-前
  557. //        position[3]=120;      // +后
  558. //        position[4]=235;      //+前
  559. //        position[5]=132;          // -后
  560. //        position[6]=127;    //+后
  561. //        position[7]=176;   // -前
  562. //        PWM_8();
  563. //   delay10ms(10);
  564. //        }
  565. //
  566. //
  567. //
  568. ////******************************************************
  569. //    for (i=0;i<40;i++)
  570. //        {
  571. //        position[0]-=1;          //-后
  572. //                if (i>36)
  573. //        {
  574. //        position[0]+=1;      //+前
  575. //        }
  576. //        position[1]-=3;          //-后
  577. //                if (i>37)
  578. //        {
  579. //        position[1]+=3;      //+前
  580. //        }
  581. //        position[2]-=1;          //-前
  582. //                if (i>27)
  583. //        {
  584. //        position[2]+=1;      //+前
  585. //        }
  586. //        position[3]-=1;      // +后
  587. //                if (i>25)
  588. //        {
  589. //        position[3]+=1;      //+前
  590. //        }
  591. //        position[4]-=4;      //+前
  592. //                if (i>35)
  593. //        {
  594. //        position[4]+=4;      //+前
  595. //        }
  596. //        position[5]+=1;          // -后
  597. //                if (i>37)
  598. //        {
  599. //        position[5]-=1;      //+前
  600. //        }
  601. //        position[6]+=1;    //+后
  602. //        position[7]-=2;   // -前
  603. //                        if (i>15&&i<32)
  604. //        {
  605. //        position[7]+=2;      //+前
  606. //        }        
  607. //                 PWM_8();
  608. //        delay1ms(5);
  609. //        
  610. //        }                  
  611. ////*************************************************************
  612. //
  613. //
  614. //
  615. // }
  616. //

  617. //----------------------------------------------------------------------------------------------------
  618. ////向左****************************************************************************************************************


  619. ////向右****************************************************************************************************************
  620. ////---------------------------------------------  
  621. //   void first ()
  622. //  {
  623. //
  624. //
  625. // uint i=0;                                                                                                                                                                                                                                                           
  626. //                for(i=0;i<1;i++)
  627. //          {
  628. //
  629. //        position[0]=108;          //-后        
  630. //        position[1]=70;          //-后
  631. //        position[2]=66;          //-前
  632. //        position[3]=92;      // +后                     
  633. //        position[4]=92;      //+前
  634. //        position[5]=167;          // -后
  635. //        position[6]=165;    //+后                                                                       
  636. //        position[7]=97;   // -前
  637. //
  638. //         PWM_8();
  639. //        delay10ms(50);
  640. //        }                                                                                                                                                               
  641. //
  642. ////*****************************************************
  643. //    for (i=0;i<41;i++)
  644. //        {
  645. //        position[1]+=1;          //-后
  646. //        position[2]+=1;          //-前   
  647. //        position[3]+=1;      // +后                     
  648. //        position[4]+=1;      //+前        
  649. //                 PWM_8();
  650. //        delay1ms(1);
  651. //        
  652. //        }
  653. //
  654. ////**************************************************************************
  655. //
  656. //
  657. //        
  658. //                        for (i=0;i<1;i++)
  659. //                {
  660. //        position[0]=108;          //-后
  661. //        position[1]=132;          //-后
  662. //        position[2]=131;          //-前
  663. //        position[3]=139;      // +后
  664. //        position[4]=137;      //+前
  665. //        position[5]=167;          // -后
  666. //        position[6]=165;    //+后
  667. //        position[7]=97;   // -前
  668. //                        
  669. //                        PWM_8();
  670. //                 delay10ms(20);
  671. //                }
  672. //
  673. //
  674. //                        for (i=0;i<1;i++)
  675. //                {
  676. //        position[0]=108;          //-后
  677. //        position[1]=132;          //-后
  678. //        position[2]=131;          //-前
  679. //        position[3]=139;      // +后
  680. //        position[4]=137;      //+前
  681. //        position[5]=204;          // -后
  682. //        position[6]=165;    //+后
  683. //        position[7]=20;   // -前
  684. //                        
  685. //                        PWM_8();
  686. //                 delay10ms(20);
  687. //                }
  688. //
  689. //                for (i=0;i<1;i++)
  690. //                {
  691. //
  692. //        position[0]=150;          //-后
  693. //        position[1]=132;          //-后
  694. //        position[2]=129;          //-前
  695. //        position[3]=139;      // +后
  696. //        position[4]=137;      //+前
  697. //        position[5]=204;          // -后
  698. //        position[6]=90;    //+后
  699. //        position[7]=20;   // -前               
  700. //                        PWM_8();
  701. //                 delay10ms(20);
  702. //                }
  703. //
  704. //
  705. //
  706. //
  707. //
  708. // }        
  709. //
  710. //
  711. //
  712. //
  713. //
  714. //
  715. //
  716. //        
  717. //        
  718. //
  719. //
  720. //
  721. // void  second ()
  722. // {
  723. //           uint i=0;
  724. //                for(i=0;i<1;i++)
  725. //          {
  726. //
  727. //        position[0]=178;          //-后
  728. //        position[1]=179;          //-后
  729. //        position[2]=174;          //-前
  730. //        position[3]=177;      // +后
  731. //        position[4]=171;      //+前
  732. //        position[5]=66;          // -后
  733. //        position[6]=63;    //+后                                                                       
  734. //        position[7]=169;   // -前        
  735. //            PWM_8();
  736. //           delay10ms(50);
  737. //           }
  738. //
  739. ////**************************************************************
  740. //    for (i=0;i<41;i++)                                                                                                                                                                                                                                 
  741. //        {
  742. //        position[0]-=1;          //-后
  743. //        position[5]+=1;          //-前   
  744. //        position[6]+=1;      // +后                     
  745. //        position[7]-=1;      //+前
  746. //        if (i>36)
  747. //        {
  748. //        position[7]+=1;      //+前
  749. //        }        
  750. //                 PWM_8();
  751. //        delay1ms(1);
  752. //        
  753. //        }
  754. //
  755. ////**************************************************************
  756. //                for (i=0;i<1;i++)
  757. //                {
  758. //        position[0]=136;          //-后
  759. //        position[1]=179;          //-后
  760. //        position[2]=174;          //-前
  761. //        position[3]=177;      // +后
  762. //        position[4]=171;      //+前
  763. //        position[5]=130;          // -后
  764. //        position[6]=130;    //+后
  765. //        position[7]=132;   // -前               
  766. //                        PWM_8();
  767. //                 delay10ms(20);
  768. //                }
  769. //
  770. //                for (i=0;i<1;i++)
  771. //                {
  772. //        position[0]=136;          //-后
  773. //        position[1]=254;          //-后
  774. //        position[2]=174;          //-前
  775. //        position[3]=177;      // +后
  776. //        position[4]=202;      //+前
  777. //        position[5]=130;          // -后
  778. //        position[6]=130;    //+后
  779. //        position[7]=132;   // -前               
  780. //                        PWM_8();
  781. //                 delay10ms(20);
  782. //                }
  783. //
  784. //                for (i=0;i<1;i++)
  785. //                {
  786. //        position[0]=136;          //-后
  787. //        position[1]=254;          //-后
  788. //        position[2]=124;          //-前
  789. //        position[3]=120;      // +后
  790. //        position[4]=202;      //+前
  791. //        position[5]=130;          // -后
  792. //        position[6]=130;    //+后
  793. //        position[7]=132;   // -前
  794. //        PWM_8();
  795. //   delay10ms(20);
  796. //        }
  797. //
  798. //}                  
  799. //
  800. //
  801. //
  802. //
  803. //
  804. //////----------------------------------------------------------------------------------------------------
  805. //////向右****************************************************************************************************************
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1 发表于 2019-2-27 02:39 | 只看该作者
本帖需要重新编辑补全电路原理图,源码,详细说明与图片即可获得100+黑币(帖子下方有编辑按钮)
回复

使用道具 举报

板凳
ID:199471 发表于 2019-7-10 08:38 | 只看该作者
好东西,有没有电路图或者机器人结构图片?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表