Homemade Mending Machine

Hello,

I would like some help please!

I am going to make a vending machine from spare parts I have accumulated from old printers, toys ect.. and i have got a coin sorter for the money!

i am going to have about 6-8 motors to vend the products this will take up 6-8 outputs

I will be using 2 inputs to the arduino from a keypad using different resistance for product selection

I will be using 4 inputs to detect 4 different coins from the sorter £1, 50p, 20p and 10p

i will be needing to use the serial output (serial.begin) to show the amount of credit in the machine.

If i dont use the serial out to show the amount of credit in the machine i will use 3 outputs to light up 3 leds when the credit is at a certain threshold, e.g : led1= 30p+ and led2= 60p+ and led3= £1+

What i need help with is the programming of the money taken with adding it up and storing it in some variable and when the threshold of a value for example "a can of drink" is at 50p, the customer can select the button that corresponds with that item. (items will be, crisps= 50p, drinks 60p and chocolate bars 70p.)

So, how do i make a program that will count the coins up from the different switches being activated by the coins to then be deducted by what ever selection is being made then allowing the machine to vend.

Im quite new to this and would appreciate anyone help!

Thanks, steve

Welcome.

Sounds like a huge project to start with.

You may first want master all the examples that are included in the IDE.

We ask you to attempt to write your sketch then ask for help when you come to a problem area.

.

I agree with @LarryD. You have described an elephant. They can only be eaten in small pieces. :slight_smile:

You need to write separate short programs to figure out how to work with each part seprately. Don’t think of creating the whole project until you can do that. Note, also, that it will be much easier to get advice here for problems with small single-purpose programs.

You may find something useful in Planning and Implementing a Program

…R
PS. If you edit your Original Post you can correct the Title

Maybe he can mend the title?

I encourage you on this project. It sounds like fun, but it will be frustrating due to some timing difficulties, especially associated with the coin slots.

I suppose that your coin detector is effectively a momentary pushbutton switch. The coin hits it, it closes, possibly with bounces, then opens. In your main program loop, your are cycling through to see if a coin switch has closed. But you may be in the wrong part of the loop, and not catch it, or you may catch it, and bounces as well, so it seems as though multiple coins have dropped.

So for reliability, you probably need to intercept these switches by interrupts, and you may need pin change interrupts if you are using one of the usual Arduino siblings. But a bounce can also effect interrupts, causing more than one in a row. I’ve had that problem, so I clear interrupts in my interrupt routine and then add a delay to get beyond bounces.

So what you’re trying is doable, bitten off one step at a time, but don’t be impatient. This will take time to get right,