Ping sensor HC_-SR04 to pic 16F877A

Status
Not open for further replies.

NadaF

Newbie level 6
Joined
May 1, 2013
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,364
hi, i need help my project is taking about auto drive system, i'm using 4 ping sensor HC-SR04 and microcontroller pic 16f877a, and i have a problem with MikroC code, for calculating duration and i will use this rule to calculate the distance: (duration/29.1) / 2
i have written this code and i hope anyone to help me plz



TRISB.f1=0; // trigpin is low i/p
TRISB.f0=1; // echopin high o/p

TRISB.f1=1; // trigpin high
delay_us(10); // wait 10

duration = pulseIn(4, HIGH);
distance = (duration/29.1) / 2;
if (distance <= 400);
--> what should i write here?
delay_us(100);
}
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…