„main.py“ hinzufügen
This commit is contained in:
parent
eb7ada2f6a
commit
4050a7b3a5
|
@ -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
|
Loading…
Reference in New Issue