Discussion in "Project Help" started by    bhantadox    Nov 30, 2023.
Thu Nov 30 2023, 03:55 pm
#1
Im using 8051, LM016L and HC-SR04 for range finder but after range 9 it starts to display random stuff.


Thu Nov 30 2023, 03:56 pm
#2
unsigned int get_range(void)
{
long int timer_val;
send_pulse();
while(!INT0); //Waiting until echo pulse is detected
while(INT0); //Waiting until echo pulse changes its state
timer_val=(TH0<<8)+TL0;
lcd_cmd(0x81);
lcd_data_string("output:");
lcd_cmd(0x8a);
if(timer_val<38000)
{
cms=timer_val/59;
if (cms!=0)
{
lcd_data(cms+48);

if(cms<15)
{
P1=0xFF;
}
else

{P1=0X00;}


}
}
else
{
lcd_cmd(0x06);
lcd_data_string("Object out of range");
}
return cms;
}


[ Edited Thu Nov 30 2023, 03:57 pm ]
Thu Nov 30 2023, 03:58 pm
#3
Image
Fri Dec 08 2023, 08:50 am
#4
We need to see the rest of your code.
Comments to explain what is supposed to happen would be useful.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm