欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
51單片機控制陀螺儀
[打印本頁]
作者:
韓剛
時間:
2018-4-13 23:29
標題:
51單片機控制陀螺儀
#include<reg52.h>
sbit hui = P1^0;
sbit dir = P1^1; //這是電機的正反轉
sbit shineng = P1^2; //電機使能端
int qw =9;
char quanshu = 0; //保存旋轉的圈數
int main()
{
int counter = 0;
int i; int j;
for( i = 0;i<200;i++)
{
for( j= 0;j<100;j++)
{
;;
}
}
TMOD = 0x21;
TH0 = (65535-qw)/256;
TL0 = (65535-qw)%256;
TH1 = 0xfd;
TL1 = 0xfd;
SM0 = 0; //串口SM0和SM1是工作方式選擇位
SM1 = 1;
REN = 1; //串口允許接受
EA = 1; //總中斷
ES = 1; //串口中斷
TR1 = 1; //打開定時器1
TR0 = 1;
shineng = 0;
while(1)
{
if(TF0 == 1)
{
TF0 = 0;
TH0 = (65535-qw)/256;
TL0 = (65535-qw)%256;
hui = !hui;
}
;
}
while(1)
{
if(quanshu != 0)
{
if(TF0 == 1)
{
TF0 = 0;
TH0 = (65535-qw)/256;
TL0 = (65535-qw)%256;
hui = !hui;
counter++;
}
if(counter == 396)
{
counter = 0;
quanshu--;
;
}
}
else
{
TR0 = 0;
hui = 0;
shineng = 1;
}
}
}
void asd() interrupt 4
{
RI = 0;
quanshu = SBUF;
TR0 = 1; //如果接受的到了數據就把計數器打開
shineng = 0;
}
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1