But i had a raspberry pi 1 and pi 2. the program works fine on pi 1 but it doesnt work well on pi 2.
or is there any semaphore setting i'm able to edit from?
have been searching for solutions online for multitreading, processing. would appreciate much if anyone could help me. thx alot!
Code: Select all
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(7, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(10, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def main():
def checkLight(channel):
while 1:
print '1'
time.sleep(0.5)
if GPIO.input(7) == 1:
break
GPIO.add_event_detect(7, GPIO.FALLING, callback = checkLight , bouncetime=300)
def checkLight2(channel):
while 1:
print '2'
time.sleep(0.5)
if GPIO.input(10) == 1:
break
GPIO.add_event_detect(10, GPIO.FALLING, callback = checkLight2 , bouncetime=300)
if __name__ == '__main__':
main()