Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Ping sensor HC_-SR04 to pic 16F877A

Status
Not open for further replies.

NadaF

Newbie level 6
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top