标题: 单片机步进电机仿真89c51+uln2004a [打印本页]

作者: 1263726410    时间: 2020-5-9 22:25
标题: 单片机步进电机仿真89c51+uln2004a
  1. #include<reg51.h>
  2. #include<absacc.h>
  3. #define uint unsigned int
  4. #define uchar unsigned char
  5. void delay(uint x);
  6. void out(char state)
  7. {
  8.         code uchar table[]={0x03,0x09,0x0c,0x06}; //反转
  9. //        code uchar table[]={0x03,0x06,0x0C,0x09};//正转
  10.         P1=table[state];
  11. //        PORT=table[state];
  12.         delay(8);
  13. }


  14. uchar phase=0;
  15. //out(uchar x);
  16. void main()
  17. {
  18.         for(;;)
  19.         {
  20.                 out(phase=++phase&0x03);//调用输出函数
  21.         }
  22. }

  23. void delay(uint x)
  24. {
  25.         uchar j;
  26.         while(x-->0)
  27.         {
  28.                 for(j=0;j<125;j++)
  29.                 {;;}
  30.         }
  31. }
复制代码


51hei截图20200509222359.png (105.42 KB, 下载次数: 41)

51hei截图20200509222359.png

步进电机仿真.zip

38.39 KB, 下载次数: 24, 下载积分: 黑币 -5






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1