智能小車循跡記時(shí)測(cè)速程序
原理圖及其完整程序下載:http://www.51hei.com/bbs/dpj-19526-1.html
下面是部分程序:
#include
unsigned int i=0;
sbit P36=P3^6;
sbit P10=P1^0; //循跡口
sbit P11=P1^1;
sbit P12=P1^2;
sbit P14=P1^4; //電機(jī)口
sbit P15=P1^5;
sbit P16=P1^6;
sbit P17=P1^7;
unsigned char j,time;
unsigned int kop,dr;
unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char c[4]={0xff,0xff,0xff,0xff},d[4];
void delay(unsigned char z) //延時(shí)子程序
{
unsigned char j;
while(z--)
for(j=123;j>0;j--);
}
void main()
{
TMOD=0x15; // 打開定時(shí)器和計(jì)數(shù)器
TH0=0x00;
TL0=0x00;
TH1=0XFc; //1ms
TL1=0X18;
EA = 1;
ET0=1;
ET1=1;
TR1 = 1;
TR0 = 1;
評(píng)論