I'm a newbie and I'm trying to learn to program with C.
What's the best way to avoid getting lots of ones when you push a button or get a signal from a sensor? interruption with RB0? or a delay? (I don't like delays because I need the program to keep running) or is there an edge function?
Thanks for your help
Last edited by danielpepo on Mon Apr 12, 2010 10:30 pm; edited 1 time in total
Thanks for your help.
What if using your button.c code I don't want the delay and the auto-repeat to work?
I want to make a counter which only counts once when the button is pressed, the button could stay pressed indefinitely.
danielpepo
Joined: 12 Apr 2010 Posts: 5
Posted: Wed Apr 14, 2010 3:13 am
I just found out if I load 255 on delay, it doesn't repeat.
I couldn't understand one thing from your button code, How can you know 50 would be 500ms and so on?
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Apr 14, 2010 10:38 am
Look in the while() loop in the main program. It has a delay_ms(10)
statement at the end. This means the counters will count in 10ms
increments. A count of 50 gives 50 x 10ms = 500 ms.
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