Total Newbie and not sure what to search for

#1

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.

TR

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

Press button pulse-on-true decreases by 1 , if need decreases continuosly used flip-flop for enable or disable clock.

0 Likes

#5

Yes but only works the once. for example 9 becomes 8… but then counts up again, but the button wont reduce the count

0 Likes

#6

Is only an idea,

0 Likes

#7

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.

0 Likes

#8

The first sample was counting but the button wouldn’t repeat its function. Does it need a repeat function

0 Likes

#9

Do not take these examples as a program, they are just simple ideas of how to connect some nodes.

0 Likes

#10

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

0 Likes

#11

I understand.
I just don’t know how to make the button function work again once its been fired.

0 Likes

#12

every time you pulse you must activate, if not active, maybe you are missing a pull-up resistor

0 Likes

#13

My quick test had no resister. I’ll re try

0 Likes

#14

Here is my first attempt with your help.

.

0 Likes

#15

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).

0 Likes

#16

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.

0 Likes

#17

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.

0 Likes

#18

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

0 Likes

#19

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.

0 Likes

#20

@rolly23 check out what I’ve done for you :wink:

I want pay your attention on few things:

  1. Only one place to hold the state (account). So we get rid of the problems with resetting couple of counters.
  2. Easily adding another coin values by expanding select node.
  3. 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 :thinking:

Feel free to comment and criticize it or suggest improvements :slight_smile:

P.S.
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”.

2 Likes