Files
2026-09-14 12:43:38 +02:00

22 lines
701 B
Python
Executable File

import RPi.GPIO as GPIO
import time
# for GPIO numbering, choose BCM
#GPIO.setmode(GPIO.BCM)
# or, for pin numbering, choose BOARD
GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BOARD) # sets numbering system of GPIO pins
channel1 = 15 # Replace MY_BOARD_PIN_ID with your actual pin number
channel2 = 16 # Replace MY_BOARD_PIN_ID with your actual pin number
GPIO.setup(channel1, GPIO.IN) # set the GPIO pin as an input
GPIO.setup(channel2, GPIO.IN) # set the GPIO pin as an input
# then some code where you read the input as many times as needed:
while(True):
value1 = GPIO.input(channel1)
value2 = GPIO.input(channel2)
print("1:%d\n"%value1)
print("2:%d\n"%value2)
time.sleep(0.5)