code for sensor HC-SR04 with pic 16f877a using mikroc language

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
Activity points
1,364
now i'm make a project that when i press a push button for a Time then when i leave this push button , i need to make a led on for the same time that i pressed the push button by using timer 1 on pic 16f877a how to do that ?!
my code :

int Duration;
int TimeValue;
void main()
{
TRISB.B7=1; // i/p for pic --> push button
TRISB.B6=0; // o/p for pic --> led
while (1)
{
if (PORTB.B7=1)
{
T1CON=0001001; // timer1 on
if (PORTB.B7=0)
{
T1CON=00000000; // timer1 off
}
Time= TMR1L;
PORTB.B6=1;
// here how to delay led on the same time that i pressed the button???
}
}
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…