Skip to content
Snippets Groups Projects
Select Git revision
  • 07ba1d8057e1bee6b7ed14a4d51815ef3161dd77
  • parser default protected
2 results

util.py

Blame
  • callback.py 567 B
    #!/usr/bin/env python2
    
    import RPi.GPIO as g
    import time
    
    g.setmode(g.BCM)
    
    # pins = range(0, 26)
    
    # for pin in pins:
    #     g.setup(pin, g.IN)
    
    pins = [ 5, 6 ]
    
    # while True:
    #     #for pin in pins:
    #     input = g.input(pin)
    #     if input:
    #         print "pin {0} is high".format(pin)
    
    def callback_rise(pin):
        print "rise", pin
    
    def callback_fall(pin):
        print "fall", pin
    
    for pin in pins:
        g.setup(pin, g.IN)
        g.add_event_detect(pin, g.RISING, callback=callback_rise)
        #g.add_event_detect(pin, g.FALLING, callback=callback_fall)
    
    time.sleep(1000)