This program is pretty simple. Whenever a user waves both hands across 2 PIR sensors, it should print out a message in console that displays which GPIO ports has being activated. The raspberry pi uses GPIO ports 4 and 17 to read data from the sensor.
I receive this error message whenever I try to print out displays the GPIO ports that has being activated.
Traceback (most recent call last): File "peter.py", line 27, in <module> print("GPIO pin %s is %s" % (sensor, new_state, sensor2, new_state2)) TypeError: not all arguments converted during string formatting
This is the code.
import RPi.GPIO as GPIO import time sensor = 4 sensor2 = 17 GPIO.setmode(GPIO.BCM) GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN) GPIO.setup(sensor2, GPIO.IN, GPIO.PUD_DOWN) previous_state = False current_state = False previous_state2 = False current_state2 = False while True: time.sleep(0.1) previous_state = current_state previous_state2 = current_state2 current_state = GPIO.input(sensor) current_state2 = GPIO.input(sensor2) if current_state2==True and current_state != previous_state2 and previous_state ate==False: new_state = "HIGH" if current_state else "LOW" new_state2 = "HIGH" if current_state2 else "LOW" print("GPIO pin %s is %s" % (sensor, new_state, sensor2, new_state2))