Can someone please help me....
I have an Arduino uno r3, and just bought an xband parallax sensor (http://www.parallax.com/Portals/0/Downl ... r-v1.1.pdf)
I would like to learn how to use the attachInterrupt to read the pulses and wrote this code which seems to work but a little slow.
- Code: Select all | TOGGLE FULL SIZE
int xbandTrigger = 0; // interrupt pin #2
volatile int pulse = 0; // count the # of times the incoming xband
// pulse changes from low to high
int oldpulse = 0;
attachInterrupt(xbandTrigger, count, RISING);
pulse = 0;
My questions. 1. Does the interrupt work in the background and counts the pulse on each rise, even while processing the print statement in the loop section? or on each rising pulse the program goes to the count() function, and when there is no pulse the program is allowed to print?
2. When there is no movement, how would I reset the pulse to 0?