51单片机超声测距程序.docVIP

  • 10
  • 0
  • 约2.04千字
  • 约 10页
  • 2018-07-04 发布于浙江
  • 举报
51单片机超声测距程序

//超声波测距,测距范围2cm-400cm;#includereg52.h#includeintrins.h#define uint unsigned int#define uchar unsigned charsbit trig=P1^0;sbit echo=P3^2;sbit test=P1^1; //测试灯sbit dula=P2^6;sbit wela=P2^7;sbit BEEP=P2^3;uint timeh,timel,distance;uint ge,shi,bai,xiaoshu,flag,time;/*共阴极数码管不带小数点代码表*/uchar code list[]={0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d ,0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c ,0x39 , 0x5e , 0x79 , 0x71 };/*共阴极数码管带小数点代码表*/uchar code listtwo[] = {0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};/*长延时函数*/void delay(uint z){ uint x,y; for(x=z;x0;x--) for(y=100;y0;y--); }/*短延时函数*/void de

文档评论(0)

1亿VIP精品文档

相关文档