标题:
求教,单片机循迹小车写了调速程序,但调速不成功。
[打印本页]
作者:
啊实打实的1312
时间:
2019-10-27 17:26
标题:
求教,单片机循迹小车写了调速程序,但调速不成功。
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
sbit IN1=P1^2;
sbit IN2=P1^3;
sbit IN3=P1^4;
sbit IN4=P1^5;
sbit L=P1^6;
sbit R=P1^7;
uchar time;
void main()
{ time=0;
TMOD=0x01;
TH0=0xff;//(65536-10)/256;
TL0=0xf7;//(65536-10)%256;
EA=1;
ET0=1;
TR0=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void tim0() interrupt 1
{
TR0=0;
TH0=0xff;//(65536-10)/256;
TL0=0xf7;//(65536-10)%256;//0.01ms
TR0=1;
time++;
if(time>=100)
time=0;//1khz
if(time<=20)
{ if(L==0&&R==0)
{
IN1=1;
IN2=0;
IN3=1;
IN4=0;
}
if(L==1&&R==1)
{
IN1=0;
IN2=0;
IN3=0;
IN4=0;
}
}
if(time<=50)
{ if(L==0&&R==1)
{
IN1=0;
IN2=1;
IN3=1;
IN4=0;
}
if(L==1&&R==0)
{
IN1=1;
IN2=0;
IN3=0;
IN4=1;
}
}
}
作者:
man1234567
时间:
2019-11-6 20:47
http://www.51hei.com/bbs/dpj-79549-1.html
你只写了四态调整,并没有写调速,请参照上贴自己改。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1