EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / YOU HAVE ANY IDEA HOW TO

YOU HAVE ANY IDEA HOW TO

|

Microcontroller › 8051 › MICRO CONTROLLER BASED ULTRASONIC DISTANCE MEASUREMENT SYSTEM › YOU HAVE ANY IDEA HOW TO

March 25, 2014 at 8:05 am #11381
amit d vekariya
Participant

YOU HAVE ANY IDEA HOW TO INTERFACE BUZZER IN THIS PROJECT AT PERTICULAR DISTANCE…..

 

 

SUPOSE DISTANCE REACHS AT 100CM AND BUZZER WILL ACTIVATE AUTOMATICALLY…PLZ ANY ONE HAVING ANY IDEA THEN REPLAY…

 

 

MY  PROGRAMM….

 

 

 
#include<REGX51.h>
 
#include<intrins.h>
 
 
sfr16 DPTR =0x82;
 
sbit trig=P3^7;
 
unsigned int target_range=0;
 
 
void delay(unsigned int t)
{ unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<111;j++);
}
 
 void lcddata(unsigned char a)
{ unsigned char q;
q=a;
 
a=a & 0xf0;
a=a >> 2;
P1=a | 0x03;
delay(1);
P1_1=0;
 
delay(1);
q=q & 0x0f;
q=q << 2;
P1=0x03 ;
P1=q | 0x03;
delay(1);
P1_1=0;
}
 
 
   
void lcdcmd(unsigned char a)
{ unsigned char q;
q=a;
a=a & 0xf0;
a=a >> 2;
P1=0x02;
P1=a | 0x02;
delay(1);
P1_1=0;
 
delay(1);
q=q & 0x0f;
q=q << 2;
P1=0x02 ;
P1=q | 0x02;
delay(1);
P1_1=0;
}
void send_pulse(void)
{
  
TH0=0x00;
  
TL0=0x00;
  
trig=1;
  
_nop_();_nop_();_nop_();_nop_();_nop_();
  
_nop_();_nop_();_nop_();_nop_();_nop_();
  
trig=0;
 
}
 
 
 
 
unsigned char get_range(void)
 
{
  
unsigned char range;
  
send_pulse();
  
while(!INT0);  
  
while (INT0);
  
  
DPH=TH0;
  
DPL=TL0;
  
TH0=0xFF;
  
TL0=0xFF;
  
  
 
if(DPTR<35000)
 
range=DPTR*1.085/59;
  
else
 
range=0;
  
return range;
 
}
 
 
 
 
void main()
 
{ unsigned char x,y,z;
  
TMOD=0x09;
  
TR0=1;
  
TH0=0x00;
  
TL0=0x00;
 
  
P0=0xff;
  
P3_2=1;   
  
 
P0=0XFF;
delay(1);
 
lcdcmd(0x33);
delay(1);
 
lcdcmd(0x32);
delay(1);
 
lcdcmd(0x28);
delay(1);
 
lcdcmd(0x0c);
delay(1);
 
lcdcmd(0x01);
delay(1);
 
lcdcmd(0x80);
delay(1);
 
 
 
lcddata(‘D’);
delay(1);
lcddata(‘i’);
delay(1);
lcddata(‘s’);
delay(1);
lcddata(‘t’);
delay(1); 
lcddata(‘a’);
delay(1);
lcddata(‘n’);
delay(1);
lcddata(‘c’);
delay(1);
lcddata(‘e’);
delay(1);
lcddata(‘:’);
delay(1);
 
  lcdcmd(0x8c);
 
lcddata(‘c’);
delay(1);
 
lcddata(‘m’);
delay(1);
 
 
while(1)
  
{   lcdcmd(0x89);
 
 
target_range=get_range();
target_range=target_range%1000;
 
z=target_range/100;
lcddata(z|0x30);
 
target_range=target_range%100;
 
x=target_range/10;
lcddata(x|0x30);
 
y=target_range%10;
lcddata(y|0x30);
 
  delay(500);
 
 
}
  
}
 
 
 

RSS Recent Posts

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy | Advertising

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise