Vending machine | Multiple motors to control

I am doing a project for school. i am building a vending machine with an Arduino the only problem i am facing is how i am going to control the motors in the machine. I have searched and found the motor control boards from Arduino which i think will be easiest to work with but the problem is that they only support 2 motors whilst I have 9 motors to conrtrol :(. Can i stack them? or do I have to connect them individually with the arduino? I have no idea and I am sorry to have to ask you but please help me.

I have an Arduino due R3-E (with a atmega16U2 chip I believe)

Do you need the motors to turn in both directions, or just one?
Both directions, you need an H-bridge per motor.
Just one, you can use a simpler one transistor drive. has motor drivers you may want to look at also vs multiple shields which will have conflicting pins and somewhat confusing power connections.

Great Thanks man,

No turning one way is good enough for me. And I also found a video onyoutube of someone using a MOSFET do you know if it is possible to use multiple of those in case I have to make them turn two directions?

Again thank you so much for answering you are the most awesome person I have met in a while!

Yes, need 4 MOSFETs per motor to turn in both directions.
Two more NPNs also if the motor supply voltage is more than 5V.
Use parts with Logic Level gates (vs Standard (10V) gates) if supply voltage is < 10V.

Sweet Thx,

one last question than I wont bother you any more than i already have. Is there a limit to the amount of shield you can attach to an arduino? for instance do I have to watch out that the motor shields are not drawing to much? can attaching to many shields damage my arduino?

Again thank you so much it is really aprreciated you really are awesome!

No turning one way is good enough for me.

In that case you just need one mosfet per motor.


MAXaddictable: Is there a limit to the amount of shield you can attach to an arduino? for instance do I have to watch out that the motor shields are not drawing to much?

Since you're not drawing any current from the arduino (apart from the miniscule amount from the output pins), you'd be able to hang a motor off of every available pin without any bother.

You are going to use an external power supply for the motors aren't you?

hey KenF,

yeah probably from the wall when i figure out how thank you so much! all of you! you have been a great help for me. I could not have done this without you guys

I have a question: what kind of motors are in this vending machine? It’s been quite a few years since I’ve worked on a vending machine, but back when I did 100% of the motors and solenoids ran off of the normal household AC voltage.

The discussion so far has assumed that these are low voltage DC motors. If the motors in this vending machine are line voltage AC, the circuits described so far won’t work. In that case, you’re probably looking at mechanical or solid state relays.

hey ShapeShifter,

initially i had made a sketch of the circuit you are describing where the arduino controls the relays according to the picture I hopefully attached to this. I looked up some ways of controlling motors and D/C motors are really the only ones that i can find information on controlling them. I saw a video of someone making a rc car with one of the arduino shields and figured that those would be the relays from my sketch. I have no idea how else to do this cause I have never done this and now that i read your post i think i probably am going all wrong with this.

If you have an idea of how better to do this than please let me know since i dont even know what kind of motors to buy:(

Anyway Thank you so much for posting here I really appreciate it

MAXaddictable: i dont even know what kind of motors to buy:(

OK, that's good information: you are not dealing with an existing vending machine that you are trying to control, so you can choose the kind of motors you want. In that case, I would stay away from AC motors and stick with low voltage DC motors (assuming that they will have enough power for what you want to do.)

The circuit you have will work for DC motors, but a MOSFET as described earlier would probably be better. Your relay circuit would also work with AC motors, except that you would want to completely isolate the AC power paths from the DC control paths. As it is drawn now, the motors use the same power supply as the Arduino, you would need to make sure there is no connection from the AC motor supply to the DC Arduino supply.

You are much better off (and much safer) sticking with DC motors. Do you need to actually make a working vending machine? In that case, the speed and power of the motors are important. Or do you just need to make a simulation where pressing a button causes a motor to spin for a few seconds, but that motor isn't really hooked up to something? In that case, just about any small motor would work.

I have to make a working vending machine butit would be a miniature version of the ones we see now. I dont know the real size yet cause i was gonna base that of the electronics.

btw how do i split the dc from the ac. Do i need a battery pack for the arduino and a psu for the motors?

I know that i have said this in earlier posts but thank you so much cause I am just like i blind person here and you guys are helping me walk

I would definitely stay with DC motors, they are a lot easier to work with, and shouldn't be a problem with a smaller scale model.

I would still use a separate power supply for the motors and the Arduino. Hook up the power to the Arduino like you normally would. Then connect the negative side of both power supplies together, they should be connected connected to the Arduino ground. Finally, connect the positive side of the motor supply to the top connection shown in KenF's MOSFET diagram.

Now I get it yeah, thnx

And i could use the arduino motor control shield as mosfet? If so what motor do I buy (what voltage)?

It looks like the Arduino motor control shield can control two motors up to 46 Volts and up to 2 Amps. However, I don't think that's a very good shield for you because you need to control so many motors. The control pins for the shield are hard-wired to certain Arduno pins. So if you stack multiple shields to increase your motor count, you are just going to be controlling multiple motors in parallel: you won't be able to individually control them. If you don't stack them, but separate them and hard-wire jumpers between the Arduino and the shields, you could get individual control of more motors, but you still need at least one digital output per motor.

It's a bit pricey (but less than a stack of Arduino Motor Shields) and I've not used it personally, but this shield looks like it could be very interesting for your application: 4x4 Driver Shield

It has 16 outputs that can drive DC loads of up to 30 Volts and up to 5 Amps. (I would be conservative and not use more than 24 Volts and keep it to no more than 2 or 3 Amps per motor.) I would think that it could handle your 9 motors with ease, and still have 5 extra outputs for indicators or other uses. And the best part is that it controls these 16 outputs with just four digital I/O lines, leaving a bunch of pins for the rest of your project.

I am guissing that the weird port up top is for the motors. and I have to connect every motor to two pins?

anyways thanks cause this is way cheaper than buying 5 arduino motor shields so I owe you big time

Yes, the 25 pin connector in the top middle is where all of the high power connections are made. Take a look at the User Manual, at Table 3 starting on page 5. There are several VCCx pins, and OUTx pins. You connect a motor (or other high power device) between an OUT pin and your power supply ground. Then you connect the power supply positive to the corresponding VCC pins (there is a pair of VCC inputs for each group of four outputs.) Finally, you also connect the power supply ground to the GND pin.

These are high side switches: you feed in the power supply positive to a common pin, and it switches the power on several outputs. You hook the load between the switched output and your power supply ground. These are simple on/off switches: you cannot PWM the output to control power level, and you can't wire them up as H-bridges to control polarity and motor direction.

So I cant program the speed of the motor and the direction but i can let a motor run or not run. If so than that is enough cause for my design I dont need directional or differnces in speed.

So ok thx. this time I think it really might be my last question :D

what motor specs do you recommend cause if i know what i should look for i can start buillding this thing

Btw are all of you guys ok with me mentioning you in my paper about this?

MAXaddictable: what motor specs do you recommend cause if i know what i should look for i can start buillding this thing

It would all depend on your needs... what kind of speed and torque do you need for your machine? It's all part of the mechanical design process.

As far as the driver board is concerned:

ShapeShifter: It has 16 outputs that can drive DC loads of up to 30 Volts and up to 5 Amps. (I would be conservative and not use more than 24 Volts and keep it to no more than 2 or 3 Amps per motor.)

So you should be able to use anything that falls within these limits. You can use motors that draw less current with no problem, just not more than the ratings. You can also use motors that need up to the rated voltage, you just have to be sure that the power supply puts out the right voltage and enough current to drive the motors.

Keep in mind that what you want are regular DC motors (often called hobby motors) and not stepper motors.