zoukankan      html  css  js  c++  java
  • 步进机

    //步进机

    #include<reg52.h>

     unsigned char code Frea[]={  //步进机节拍方向的IO口

            //逆时针转动

             //0x0e,0x0c,0x0d,0x09,0x0b,0x03,0x07,0x06

             //顺时针转动

             0x06, 0x07,0x03,0x0b,0x09,0x0d,  0x0c,0x0e

     };

     void delay(){

             unsigned char i=200;

             while(i--);

     }

     void main(){

            unsigned char tmp;           //暂存变量

             unsigned char index = 0;  //节拍调用索引

             while(1){

                       tmp = P1;   //绑定P1口

                       tmp = tmp & 0xf0;     //清零低四位

                       tmp = tmp | Frea[index];  //节拍或f赋值

                       P1 = tmp;                      //绑定步进机IO口

                       index++;

                       index = index & 0x07;

                       delay();

             }       

     }

  • 相关阅读:
    POJ 2065 高斯消元求解问题
    HDU1045-Fire Net
    HDU1863-畅通工程
    POJ2524-Ubiquitous Religions
    POJ1064-Cable master
    POJ2456-Aggressive cows
    HDU1272-小希迷宫
    POJ1611-The Suspects
    HDU4496-D-City
    HDU1232-畅通工程
  • 原文地址:https://www.cnblogs.com/robotes/p/7689368.html
Copyright © 2011-2022 走看看