<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR128的程序——步進(jìn)電機(jī)點(diǎn)動(dòng)正反控制

          AVR128的程序——步進(jìn)電機(jī)點(diǎn)動(dòng)正反控制

          作者: 時(shí)間:2016-11-22 來(lái)源:網(wǎng)絡(luò) 收藏
          #include
          #include
          #define uchar unsigned char
          #define uintunsigned int
          uchar step_table[]={0xf1,0xf2,0xf4,0xf8};
          uchar step_table1[]={0xf8,0xf4,0xf2,0xf1};
          void Delayms(uint MS);
          void mcu_init(void)
          {
          DDRA=0XFF;
          PORTA=0XFF;
          DDRC=0XFF;
          PORTC=0XFF;
          DDRF|=0X0E;
          PORTF|=0X0E;
          PORTF&=0xF8;
          DDRB |=0X1f;
          PORTB|=0X1f;
          DDRD = 0x00;
          PORTD = 0XFF;
          }
          void main(void)
          {
          uint i,a1=0,a2=0;
          mcu_init();
          while(1)
          {
          if((PIND&0x01)!=0X01)
          {
          Delayms(5);
          if((PIND&0x01)!=0X01)
          {
          a1=1;
          while(a1)
          {
          PORTA=0XFE;
          for(i=0;i<4;i++)
          {
          PORTB = step_table[i];
          Delayms(3);
          }
          if((PIND&0X01)!=0X00);
          {
          PORTA=0XFF;
          a1=0;
          }
          }
          }
          }
          if((PIND&0x02)!=0X02)
          {
          Delayms(5);
          if((PIND&0x02)!=0X02)
          {
          a2=1;
          while(a2)
          {
          PORTA=0XEF;
          for(i=0;i<4;i++)
          {
          PORTB = step_table1[i];
          Delayms(3);
          }
          if((PIND&0X02)!=0X00);
          {
          PORTA=0XFF;
          a2=0;
          }
          }
          }
          }
          }
          }
          void Delayms(uint MS)
          {
          uint i,j;
          for( i=0;i
          for(j=0;j<1141;j++);
          }


          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();