Raspberry Pi Coin Counter (RPi-GPIO)

I have a problem counting coins in raspberries pi B + usin RPi-GPIO.

This is the code:

import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) while True: print(GPIO.input(23)) 

I called the manufacturer and he said that the coin counter sends an impulse with a value of 1 constantly and a value of 0 when the coin falls. But the console displays 0 and 1 in random order. And nothing changed when the coin fell.

4-wire outputs:

  • Black and red: 12v (font)
  • White: this is an impulse (1 constantly, 0 when a coin is thrown). It is connected to the raspberries of the 23rd pin (I choose this pin because it is available).
  • Purple: This is a coin count on a split LED.

Voltage: 12v font and pulse (white wire) are 0.19 ~ 0.25 volts

Note: pulse is digital.

I have a coin counter:

enter image description here

+6
source share
1 answer
 import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) counterPin=23 GPIO.setup(counterPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(counterPin) if input_state == False: print('coin dropped') 
+1
source

All Articles