Asked
Viewed 17 times
0
I’m trying to use gpiozero for my coin acceptor, I tried using DigitalInputDevice but it doesn’t give back the value of what coin I’m inserted.
How can I use gpiozero to accept values from my coin acceptor and store it on my Python script?
import gpiozero
coin = gpiozero.DigitalInputDevice(21)
On insert coin
coin.value
0
I’m looking to accept values of 1, 5 and 10 from one GPIO pin from the coin acceptor
Coin pin is inserted on BOARD40
Common GND pin is inserted on BOARD39 to power GND
Coin slot ground connected to power supply GND
Generic coin acceptor for Philippine coins https://shopee.ph/Allan-Universal-Coin-Slot-for-1-5-10-Pesos-i.24440819.1055957120
New contributor
-
You might want to include more details about said coin acceptor (make&model, datasheet, …), your wiring, among other related stuff. I am not entirely sure what you are expecting of a single digital input. – Ghanima♦ 5 hours ago
-
@sudo, I could not find the user manual for your coin slot. Can you give us a link to it? Or is your coin slot similar to the video below? (1) Allan Universal Coin Slot for 1, 5,10 Pesos, shopee.ph/… (2) How to setup coin acceptor on raspberry pi retropie 55,265 views 2017may24 youtube.com/watch?v=plG0ZpbN–s. – tlfong01 4 hours ago
-
@sudo, More References, AdaFruit is usuallty good: (1) Karlsson Programmable Three Coin Types Coin Acceptor – US$20 kr4.us/coin-acceptor-programmable-3-coin-types.html (2) Karlsson Programmable Three Coin Types Coin Acceptor User Manual dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General/… (3) AdaFruit Programming Coin Acceptor – US$$15 adafruit.com/product/786 (4) Rpi Forum Coin Accepter Discussion raspberrypi.org/forums/viewtopic.php?t=85355#p602964 – tlfong01 3 hours ago
-
@sudo, AdaFruit has a Arduino demo program. You can also google other Arduino programs, and translate them to python and GPIOzero. – tlfong01 3 hours ago
-
youtube.com/watch?v=plG0ZpbN–s – Dougie 2 hours ago
-
@sudo, AdaFruit instruction is concise and good. We start with one value of coin and do 5 steps: To program the validator – AdaFruit adafruit.com/product/786 (1) Ppower coin reader 12VDC. Press and hold the little button on top for 5 seconds and release. The LED will be on. (2) Now insert 30 sample coins of the value you want to detect. (3) Once the LED goes out it’s programmed! (4) Connect 10K pullup from COIN wire to Rpi’s 3V3 Power. (5) Connect GPIO pin to Coin wire, (5) Insert a coin, and verify that the GPIO pulses goes high for about 40 milliseconds. – tlfong01 15 mins ago
-
@sudo, So to test one value of coin, you can use a simple python loop to do the following 3 steps: (1) Wait for GPIO pin to go low, (2) Wait 40mS for GPIO pin to go high, (3) Print “Coin accepted”. IMPORTANT WARNING: Be careful not to connect GPIO pin’s pullup 10k resistor to 5V, or your Pi will be fired. – tlfong01 10 mins ago
-
@sudo, I don’t suggest you to start with Rpi.GpioZero, which appears simple, but actually uses a rather advanced, subtle, “Declarative” programming style, which is even out of GCE A Level Computing Science syllabus which includes only the basic “Procedural”, “Functional”, and “Objected Oriented” programming paradigms. I would suggest you to start with the newbie friendly Rpi.GPIO. After you make your python/GPIO program work, then you can upgrade to GPIO.Zero. I am happy to see how you do GPIO and see if I can help when you upgrade to GPIO.Zero. Happy programming and Cheers! – tlfong01 just now Edit
Categories: Uncategorized
