欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: ULN2003步進電機只能接單片機P0口嗎 [打印本頁]

作者: 藍琪    時間: 2018-12-5 23:24
標題: ULN2003步進電機只能接單片機P0口嗎
如題,ULN2003步進電機只能接單片機P0口嗎?接到其他IO口電機不轉動,程序里也改為了其他IO口
#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int
#define MotorData P0                  //步進電機控制接口定義
uchar phasecw[4] ={0x08,0x04,0x02,0x01};//正轉 電機導通相序 D-C-B-A
uchar phaseccw[4]={0x01,0x02,0x04,0x08};//反轉 電機導通相序 A-B-C-D
//ms延時函數
void Delay_xms(uint x)
{
uint i,j;
for(i=0;i<x;i++)
  for(j=0;j<112;j++);
}
//順時針轉動
void MotorCW(void)
{
uchar i;
for(i=0;i<4;i++)
  {
   MotorData=phasecw[i];
   Delay_xms(4);//轉速調節
  }
}
//逆時針轉動
void MotorCCW(void)
{
uchar i;
for(i=0;i<4;i++)
  {
   MotorData=phaseccw[i];
   Delay_xms(4);//轉速調節
  }
}
//停止轉動
void MotorStop(void)
{
MotorData=0x00;
}
//主函數
void main(void)
{
uint i;
Delay_xms(50);//等待系統穩定
while(1)
{
  for(i=0;i<500;i++)
  {
   MotorCW();   //順時針轉動
  }
  MotorStop();  //停止轉動
  Delay_xms(500);
  for(i=0;i<500;i++)
  {
   MotorCCW();  //逆時針轉動
  }
  MotorStop();  //停止轉動
  Delay_xms(500);  
}
}



作者: 江蓬瑋    時間: 2018-12-6 09:28
GPIO都可以接啊
作者: che100    時間: 2018-12-6 09:52
其他的GPIO口也可以,如果內部無上拉,最好外部接上拉10K電阻
作者: 藍琪    時間: 2018-12-6 10:08
江蓬瑋 發表于 2018-12-6 09:28
GPIO都可以接啊

好的,謝謝,已經解決了
作者: Bensenner    時間: 2018-12-6 10:14
我記得是都可以把
作者: yang1597    時間: 2018-12-6 10:46
大佬厲害  已采納
作者: lhd123    時間: 2018-12-6 11:57
不是一定的
作者: maimai    時間: 2020-2-29 22:09
請問用這個程序仿真是不是只能正轉呀




歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1