0

I have this code that read the Raspberry Pi RPIO pin number 24, that is connected to coin acceptor and the datasheet of it is:

0,05€ - 1 pulse
0,10€ - 2 pulse each pulse in 0,025ms
0,20€ - 4 pulse each pulse in 0,025ms
0,50€ - 10 pulse each pulse in 0,025ms
1€    - 20 pulse each pulse in 0,025ms
2€    - 40 pulse each pulse in 0,025ms

And i have this code:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(24,GPIO.IN)

count = 0
euroCoin = 0

def coin(value):
  euro = value * 5
  return euro

while True:
   inputValue = GPIO.input(24)
   if (inputValue == True):
    count = count + 1
    euroCount = coin(count)
    print ("Euro "+str(euroCount)+".")
   time.sleep(.025)

That show, for example, for 0,20€ coin show:

0,05
0,10
0,15
0,20

I only need to show the final value, how i do that? Thanks

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
user3332475
  • 55
  • 1
  • 2
  • 10

1 Answers1

0

If you're terminating the program with a signal, like CTRL-C (SIGINT), you'll need to write a handler to catch that signal. Otherwise, you can't capture the value you're after.

See How do I capture SIGINT in Python?

Community
  • 1
  • 1
dwerner
  • 6,462
  • 4
  • 30
  • 44