hello ,
i want to turn on/off the LED after 5 sec using delay.
i write the following code .but its not changing the value on RD0,plz tell me where is the problem.Its my first program in C for PIC
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
Posted: Tue Jul 11, 2006 8:50 am
A classic error.
After setting the output_low a delay is missing, on the next instruction the processor will call ouput_high again. Too fast for your eye to see.
Code:
while(true)
{
output_high(pin_D0);
delay_seconds(5);
output_low(pin_D0);
delay_seconds(5); // Add this line
}
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
Posted: Tue Jul 11, 2006 8:51 am
Please post code using the code button.
You messed up in the while loop. If you follow the logic around
high
delay
low
high //you don't delay before this and you will not see the previous low
delay
low
high
...beat me by a min. :o)
huma
Joined: 23 Jun 2006 Posts: 12
Posted: Wed Jul 12, 2006 12:53 am
Thanks a lot ckielstra and treitmey.
its running well now.
Thanks once again.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum