Hi I haven’t programmed since old basic…
I’m just looking for some demos or samples to build a counter that can increase from a digital input.
Then when a button is pressed the counter decreases by 1, display the counter value on a 2 line display.
My ultimate goal once I learn these basic is to make a Photobooth controller. Coin mech pulse to set the credit counter which will allow the activate button look if 1 or greater then operates a relay.
Repeat until the credit has all been used.
Hi, here something very basic, only that you have an idea, the accountant will do it forever, just one will be subtracted with the button
What pulse type is that. As I tried your diagram and it only subtracted the number once.
Have I got a setting wrong for it to repeat
pulse-on-true decreases by 1 , if need decreases continuosly used flip-flop for enable or disable clock.
Yes but only works the once. for example 9 becomes 8… but then counts up again, but the button wont reduce the count
Given your description, this is probably exactly what you want. If someone inserts more coins, you want the credit to increase again. The only reason it keeps increasing now is because you have it connected to a clock (that never stops) instead of a coin counter.
Note that there is a subtle bug in this program that will only show up after it has been used a lot. There is a limit to how high a number “count” can hold. Once you exceed that number, it will wrap around either to zero or a large negative number and you will get a negative number displayed on the LCD. One way to avoid this is to reset both count nodes when the output for subtract is zero.
The first sample was counting but the button wouldn’t repeat its function. Does it need a repeat function
Do not take these examples as a program, they are just simple ideas of how to connect some nodes.
I wouldn’t think the coin value would be any greater then $10 when $2 / photo.
I’ll give it a go tomorrow as it late here in Oz.
I’ll try once the counter is greater than 2, it then puts a relay high to activate the release button circuit.
Once it falls below 2, it deactivated.
I’ll then add a timeout timer so if a credit is in place for 5 minutes it reset the counter to $0.
I’m hoping to use this as a fund raiser for community group at a dinner
I just don’t know how to make the button function work again once its been fired.
every time you pulse you must activate, if not active, maybe you are missing a pull-up resistor
My quick test had no resister. I’ll re try
Here is my first attempt with your help.
You probably want COST to be the step for the count node for shutter. You also don’t want shutter button to work if you don’t have enough credit.
A less-or-equal node could replace your equal/less/xor group of nodes. You probably don’t really want less-or-equal, though. You will want to know “do they have enough credit to print”; that is a less or greater-or-equal question, not less-or-equal question. If less-or-equal is true, it indicates they don’t have enough credit, or they have just enough credit, so you still don’t know if they can print.
Note that at some point your coin input will actually need to specify a value. You can’t give one credit for a penny & 1 credit for quarter (unless you only accept 1 type of coin and cost is count of that coin; i.e. you only accept quarters and a print cost is 4, or $1).
Thanks I added the equal or less and works great. The mech give pulse out depending on the coins programmed. $1 = 1 pulse, $2 = pulses. That is enough for the night.
That is 1 part of the system, now the relay driving and away to stop -1… -6 credit on the screen.
Then a time out reset, (should be easy)
I didn’t get much time tonight to try.
For a one-night fund-raiser, the “coin counter” could just be a button behind the counter that the cashier pushes for each dollar received. The time-out reset might best be done using a button behind the counter as well. A cashier would know better when it needs reset, and they can hit the coin button to add credit back in if they reset by accident.
Adding code to disable the shutter button when you don’t have credit & resetting both counters when subtract hits 0 should eliminate your negative credit issues.
I have the mechanism and it works great. Goes low on a coin pulse.
I’ll build a box to house it all.
I’ll put a timer to start from the coin pulse set to 5 minutes to go reset the credit counter to 0.
I have a USB - Joystick card I current use. So the relay will just disable the start button.
Down the track I’ll look at programming USB HID in Arduino but baby steps first.
This software is making programming so easy
If you need the relay to trigger the physical shutter, the button can be disabled via software by requiring subtract node != 0 AND button being pressed.
@rolly23 check out what I’ve done for you
I want pay your attention on few things:
- Only one place to hold the state (account). So we get rid of the problems with resetting couple of counters.
- Easily adding another coin values by expanding
- Easily extending the whole system with another actions.
Here is the xodball: photobooth.xodball (17.2 KB)
Probably, we should add this pattern to the official tutorial or even create an “account” node that will encapsulate all this logic inside
Feel free to comment and criticize it or suggest improvements
Also you can find out a similar pattern example in the
xod-dev/pn532-nfc, but with keeping state on the NFC tags. Check out “example-tickets”.