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 / please explain

please explain

|

Microcontroller › 8051 › Interfacing AT89S51 with ultrasonic sensor and LCD › please explain

January 21, 2016 at 3:42 pm #13644
Shirsendu Das
Participant

Please explain the calculation part,
And why you use for loop 10times.
And the delay function.)????!!!

void Distance_Measure()
{
count=count1=0;
TH0=0x00;TL0=0x00;
TR0=0;
for(i=0;i<10;i++)
{
TX=0;
Delay(1000);
TX=1;
Delay(10);
TX=0;
while(RX==0);
TR0=1;
while(RX==1);
TR0=0;
count=TH0<<8;
count=count|TL0;
TH0=TL0=0x00;
count1=count1+count;
Delay(5000);
}
count=count1/10;
inch1=count%10000/1000;
inch2=count%1000/100;
result=(inch1*10)+inch2;
obj_distance=result-2;
Lcd8_Decimal3(0XCb,obj_distance);
}

RSS Recent Posts

  • washing machine motor wiring June 15, 2026
  • effect of calibration on s-parameters June 15, 2026
  • Mitsubishi Electric IPM module lot code format - how to decode? June 14, 2026
  • Replacement IGBT for DGG4015 for Honda Motorcycle ECU June 14, 2026
  • TDK Lambda ESS 500-20-11-D-LB-RSTL Parallel Operation June 13, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media 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 WTWH Media
Privacy Policy | Advertising | About Us

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