Initial commit

This commit is contained in:
2026-01-02 20:52:43 +01:00
commit e9d2257d73
854 changed files with 164132 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import smbus
import time
import json
# Adressen der beiden MCP23017 Chips
MP = 0x20 # Ausgang rechte Hälfte
# Register-Adressen für den MCP23017
IODIRA = 0x00 # Eingang / Ausgang A
IODIRB = 0x01 # Eingang / Ausgang B
GPIOA = 0x12 # GPIO A
GPIOB = 0x13 # GPIO B
PULLUPA = 0x0C
PULLUPB = 0x0D
# Initialisiere den I2C Bus
bus = smbus.SMBus(1)
# Hauptprogramm
def main():
time.sleep(0.5)
for pin in range(8):
bus.write_byte_data(MP, IODIRA, ~(1 << pin))
time.sleep(0.02)
bus.write_byte_data(MP, PULLUPA, ~(1 << pin))
time.sleep(0.02)
bus.write_byte_data(MP, GPIOA, ~(1 << pin))
time.sleep(0.02)
print("====================" + str(pin) + "==========================")
wert = bus.read_byte_data(MP, GPIOA)
for j in range(8): # Lese 4*8=32 Pins
bitmaske = 1 << j
wert_bitweise = bool(wert & bitmaske)
if wert_bitweise == False and j != pin:
print(str(j))
time.sleep(0.02) # Kurze Pause, damit die Änderung sichtbar wird
if __name__ == "__main__":
main()