I'm trying to count pulses using the GPIO pins and when I run this script I get the error (it's written in leafpad then I open it in IDLE)
Traceback (most recent call last): File "/home/Pi/Desktop/revcount.py", line 10, in g.add_event_detect(2, g.RISING, callback = increase rev) RuntimeError: Failed to add edge detection
Here's the code
import RPi.GPIO as g
from time import sleep
g.setmode(g.BCM)
g.setup(2, g.IN)
global revcount
revcount = 0
def increaserev(channel):
global revcount
revcount += 1
g.add_event_detect(2, g.RISING, callback=increaserev)
while True:
sleep(60)
print "RPM is {0}".format(revcount)
revcount = 0