# This is only working on real Hardware...
from machine import TouchPad, Pin
import time
touch_pin1 = TouchPad(Pin(13, Pin.IN))
touch_pin2 = TouchPad(Pin(12, Pin.IN))
touch_pin3 = TouchPad(Pin(14, Pin.IN))
# Normalwert ca. 460 - 480
# Wird der Schwellenwert unterschritten gibt es ein Touch-Events
schwellenwert_pin1 = 350
schwellenwert_pin2 = 350
schwellenwert_pin3 = 350
# PrintOut = Sollen die Normal-Werte ausgegeben werden (True/False)
po_value = False
# PrintOut = Sollen die Touch-Events ausgegeben werden (True/False)
po_touch = False
# PrintOut = Sollen die Schummel-Zahl ausgegeben werden (True/False)
po_SCHUMMEL = True
while True:
wert_pin1 = 0
wert_pin2 = 0
wert_pin3 = 0
touch_pin1_value = touch_pin1.read()
touch_pin2_value = touch_pin2.read()
touch_pin3_value = touch_pin3.read()
if po_value == True:
print("Pin 1: {}".format(touch_pin1_value))
print("Pin 2: {}".format(touch_pin2_value))
print("Pin 3: {}".format(touch_pin3_value))
print("-------------------------")
time.sleep_ms(500)
if touch_pin1_value < schwellenwert_pin1:
if po_touch == True:
print("Touch auf Pin 1 erkannt")
wert_pin1 = 1
if touch_pin2_value < schwellenwert_pin2:
if po_touch == True:
print("Touch auf Pin 2 erkannt")
wert_pin2 = 2
if touch_pin3_value < schwellenwert_pin3:
if po_touch == True:
print("Touch auf Pin 3 erkannt")
wert_pin3 = 3
SCHUMMEL = wert_pin1 + wert_pin2 + wert_pin3
if po_SCHUMMEL == True:
print(SCHUMMEL)
time.sleep_ms(100)