„main.py“ hinzufügen

This commit is contained in:
Manuel Kamper 2023-03-28 11:48:04 +00:00
parent eb7ada2f6a
commit 4050a7b3a5
1 changed files with 35 additions and 0 deletions

35
main.py Normal file
View File

@ -0,0 +1,35 @@
import rp2
from machine import Pin
import utime as time
coinPin = Pin(0, Pin.IN, Pin.PULL_UP)
newCoin = False
pulses = 0
timeAfter = time.ticks_us()
def Coincounter(pin):
global newCoin, pulses, timeAfter
timeAfter = time.ticks_us()
newCoin = True
pulses = pulses + 1
coinPin.irq(handler = Coincounter, trigger = Pin.IRQ_RISING)
while True:
timeNow = time.ticks_us()
if ((newCoin) and (timeNow - timeAfter > 300000)):
if (pulses == 1):
print("5 Cent")
elif (pulses == 2):
print("10 Cent")
elif (pulses == 3):
print("20 Cent")
elif (pulses == 4):
print("50 Cent")
elif (pulses == 5):
print("1 Euro")
elif (pulses == 6):
print("2 Euro")
else:
print("Error")
newCoin = False
pulses = 0