The RPi setup has input Pins 20 and 21. The program is checking if the inputs are high or low constantly. If so the assigned outputs switch to high.
The unexpected result is that when e.g. Pin 20 is high Output 19 and 26 switch to high at the same time. Both inputs are recognized seperately without interferences. How can i change this result? If one input is high, one output should be high, too. No more. In the picture is the setup with a breadboard, a RPi 3 and the I/O which are connected to an I/O terminal.
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) from time import sleep GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(19, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(26, GPIO.OUT, initial=GPIO.LOW) try: while True: if GPIO.input(21): print("Sensor1 an") GPIO.output(19, 1) else: GPIO.output(19, 0) if GPIO.input(20): print("Sensor2 an") GPIO.output(26, 1) else: GPIO.output(26, 0) sleep(0.1) finally: GPIO.cleanup()
The diagram shows my breadboard with pull up resistors. I use a Raspberry Pi 3. The input signals come from a I/O terminal. Normally the input and output are connected via the I/O terminal. I installed the RPi between. How can I solve the problem, that one high detected input signal changes all of my outputs?
The black wire in No.10 is my output wire connected GPIO Pin 19 and No. 11 connected to GPIO Pin 26. If a sensor is activated a light is turned on as shown at No. 15 and 17. Wires from the sensors are connected to GPIO Pin 20 and 21. In diagram: Input 1 -> Output 2 and Input 2-> Output 1.
Without the Resistors the RPi gets problem with Floating (here: pull up resistors which lead the unexpected signals to GND; Sensor signal on HIGH to input).
Same wire color represent connected input and output via Python. -> Is Orange input wire is HIGH? Yes-> orange output wire (other pin) HIGH
On the picture is a 7" Touchscreen connected to the RPi. There are six inputs and outputs on the picture setup. I tried to extend the previous setup to six sensors.