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
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;
void setup()
{
Serial.begin(9600);
attachInterrupt(xbandTrigger, count, RISING);
pulse = 0;
}
void loop()
{
Serial.println(pulse);
delay(100);
}
void count()
{
pulse++;
}
2. When there is no movement, how would I reset the pulse to 0?
Thank you
Scott