This is basically a followup question to my previous questions (you don't need to read them to answer it). Primary question is, can a Raspberry Pi 2 take more than one inputs from different circuits at the same time (same code running)? I have built a functioning photogate.
Here is my circuit:
The code that I am using is:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.IN) start = time.time() stop = time.time() gateState = False try: while True: if (GPIO.input(11) != gateState): gateState = not gateState if (gateState == True): start = time.time() else: stop = time.time() if stop - start > 0.0001: print "Time: ", stop - start, "s" print "Speed: ", 1.5/(stop-start), "m/s" print " " except KeyboardInterrupt: GPIO.cleanup()
So, I was wondering, how I would use another photogate on the same Pi at the same time as the first position to measure speed of an object at two times. (basically use two photogates). How would I manipulate the code to use two photogates at the same time, that is if Pi can do it. Which GPIO would I use, (any random two?)