欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
stc15w4k32s控制步進(jìn)電機(jī)旋轉(zhuǎn)
[打印本頁]
作者:
51黑er
時(shí)間:
2015-11-1 21:37
標(biāo)題:
stc15w4k32s控制步進(jìn)電機(jī)旋轉(zhuǎn)
#include"stc15.h"
#define uchar unsigned char
#define uint unsigned int
uchar n;
uchar tab[]={ 0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09};
void delay(uchar ms)
{
unsigned int m;
while(ms--)
for(m=0;m<100;m++);
}
void bujinzheng()
{
for(n=0;n<8;n++)
{
P1=tab[n];
delay(9);
}
}
void bujinfan()
{
for(n=8;n>0;n--)
{
P1=tab[n-1];
delay(9);
}
}
void main(void)
{
uchar n,i;
while(1)
{
for(i=0;i<128;i++) //正轉(zhuǎn)90度,修改i,可修改旋轉(zhuǎn)角度,512為一圈
{
bujinzheng();
}
for(i=0;i<64;i++) //反轉(zhuǎn)45度
{
bujinfan();
}
}
}
復(fù)制代碼
#include"stc15.h"
#define uchar unsigned char
#define uint unsigned int
uchar tab[]={ 0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09};
void delay(uchar ms)
{
unsigned int m;
while(ms--)
for(m=0;m<100;m++);
}
void main(void)
{
uchar n,i;
while(1)
{
for(i=0;i<128;i++)
{
for(n=0;n<8;n++)
{
P1=tab[n];
delay(10);
}
}
for(i=0;i<64;i++)
{
for(n=8;n>0;n--)
{
P1=tab[n-1];
delay(10);
}
}
}
}
復(fù)制代碼
作者:
hsy2966
時(shí)間:
2015-11-3 19:31
#include<reg51.h>
//--定義要使用的IO口--//
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
//--聲明全局函數(shù)--//
void Delay10ms(unsigned int c); //誤差 0us
/*******************************************************************************
* 函 數(shù) 名 : main
* 函數(shù)功能 : 主函數(shù)
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
void main(void)
{
unsigned char i = 0;
while(1)
{
switch(i) //位選,選擇點(diǎn)亮的數(shù)碼管,
{
case(0):
LSA=0;LSB=0;LSC=0; break;//顯示第0位
case(1):
LSA=1;LSB=0;LSC=0; break;//顯示第1位
case(2):
LSA=0;LSB=1;LSC=0; break;//顯示第2位
case(3):
LSA=1;LSB=1;LSC=0; break;//顯示第3位
case(4):
LSA=0;LSB=0;LSC=1; break;//顯示第4位
case(5):
LSA=1;LSB=0;LSC=1; break;//顯示第5位
case(6):
LSA=0;LSB=1;LSC=1; break;//顯示第6位
case(7):
LSA=1;LSB=1;LSC=1; break;//顯示第7位
}
Delay10ms(50);
i++;
if(i == 8)
{
i = 0;
}
}
}
/*******************************************************************************
* 函 數(shù) 名 : Delay10ms
* 函數(shù)功能 : 延時(shí)函數(shù),延時(shí)10ms
* 輸 入 : 無
* 輸 出 : 無
*******************************************************************************/
void Delay10ms(unsigned int c) //誤差 0us
{
unsigned char a, b;
//--c已經(jīng)在傳遞過來的時(shí)候已經(jīng)賦值了,所以在for語句第一句就不用賦值了--//
for (;c>0;c--)
{
for (b=38;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1