Count how many pulses per second

That's because it wasn't getting enough power, probably because it's running off 5V through the internal pullup resistor which is about 20k ohms. Whatever you do, don't set that pin to OUTPUT!