这个是从一个制造成功的智能小车里边提取出来的
原理图及其完好程序下载: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; //电机口
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) //延时子程序
{
unsigned char j;
while(z–)
for(j=123;j>0;j–);
}
void main()
{
TMOD=0x15; // 翻开定时器和计数器
TH0=0x00;
TL0=0x00;
TH1=0XFc; //1ms
TL1=0X18;
EA = 1;
ET0=1;
ET1=1;
TR1 = 1;
TR0 = 1;