0

I'm having a problem to count coins in raspberry 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 the Coin Counter sends a pulse with value 1 constantly and the value 0 when the coin down. But in the console is showing 0 and 1 at random. And nothing change when coin dropped.

4 wire outputs: black and red are 12v (font), white is pulse on 23 pin (1 constantly, 0 when drop the coin) and purple is to count coins on separeted led. Font 12v, and pulse (white wire) is 0.19~0.25 volts, and I used 10k resistor in this wire. And I use Raspberry pi B+.

Obs: Pulse is digital.

I have this Coin Counter:

enter image description here

10
  • You have not wired the device to the Pi correctly.
    – joan
    Commented Oct 8, 2015 at 20:21
  • I plugged white wire on 23 pin, thats send 1 constantly and 0 when dropped the coin... Sends a 0.19~0.25v and i used a 10k resistor.
    – Radagast
    Commented Oct 8, 2015 at 20:35
  • I updated the question.
    – Radagast
    Commented Oct 8, 2015 at 20:37
  • The Pi's GPIO are all digital 0V-3.3V. A voltage of 0.19V-0.25V will always be seen as 0.
    – joan
    Commented Oct 8, 2015 at 20:45
  • '-', and how to make works? The manufacturer says: doenst matter the voltage, the 0 and 1 is always send...
    – Radagast
    Commented Oct 8, 2015 at 20:48

1 Answer 1

2

From the description it seems likely that the white pulse wire is an open collector output. In other words it floats to an external voltage and is pulled down to zero at each pulse.

Instead of

GPIO.setup(23, GPIO.IN)

use

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO 23 will then normally read 1 but will read 0 at each pulse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.