how can i add more motors to work for the arduino

                                                                         -----------------<MOTORS>-----9v
                                                                        /
                       Arduino Digital Pin 8 --------\/\/\/\/----[transistor]
                                                                        \
                                                    1k resistor          -----------------GND

all the motors should be connected in parallel, not daisy chained end to end. This is the setup for an NPN transistor, 2n2222 and TIP120 are both NPN. For a PNP transistor, the motors would go between the transistor and ground instead of between the power and the transistor. Think of the transistor as a switch. The "base" takes in a small input and turns on or off accordingly. The other two electrodes are where the power and the load go.. not so hard to understand, really. You should also have a diode to handle the flyback spike, it gets connected in "reverse" across the motor. In short, motors can cause a power spike that can kill other components unless you are careful. That diode (1N4001 is what I use, cheaper than dirt) is your protection from that spike. You could also use a smallish ceramic capacitor, but I prefer diodes as they are foolproof.

Here, I want you read this.. it covers a number of really good options in a really well done tutorial:

http://www.me.umn.edu/courses/me2011/arduino/technotes/dcmotors/motorcontrol/motorcontrol.html

When the author refers to "fancy version" of motor control, he means the chip on that controller board you pointed to. Besides being overkill, it interfaces via Serial, which is great in some respects but not so great in others. He refers to it in the section named "Bidirectional Motor Control". It's just more pain than you need and certainly more cost.

The code will be very simple. I picked pin 8 randomly by the way.

You'll just be doing:

digitalWrite(8, HIGH);

to turn the motors on, and

digitalWrite(8, LOW);

to them off.

Now, all you need to do is detect the switch and add a few delays for timing and you're cooking with gas.

first for the 9v batteries i only need for my project to run for a short period of time and also for the motors how would i put them in parallel and from that schematic do i need to multiply the components time 4 for each motor and will all four motors run at max power from one pin. also would it make any difference if i used the PWM pins from the duimilanove ATMEGA328. if so how would i make the programming to control all 4 motors
thank you for your help

P.S. would you happen to no how to program a usb host shield

p.s.s. would two motor controllers make it more complicated and time consuming?
again thank you very much for helping me

jjmuteteke:
first for the 9v batteries i only need for my project to run for a short period of time and also for the motors how would i put them in parallel and from that schematic do i need to multiply the components time 4 for each motor and will all four motors run at max power from one pin. also would it make any difference if i used the PWM pins from the duimilanove ATMEGA328. if so how would i make the programming to control all 4 motors
thank you for your help

I've updated focalist's schematic to (hopefully) make it more clear how to hook things up (and to label the pins of the transistor); the collector of the transistor goes to the motors, the base of the transistor to the resistor (and on to the Arduino), and the emitter goes to ground. I've shown three motors connected to the transistor in a parallel configuration - I'm sure you can see how to add the fourth:

                                                                                      +----[Motor1]-----+
                                                                                      |                 |
                                                                         +------------+----[Motor2]-----+---- 9 VDC
                                                                         |            |                 |
                                                                         |            +----[Motor3]-----+
                                                                         |            |                 |
                                                                         |            +-------->|-------+
                                                                         |               Flyback Diode (1n4001 or similar)
                                                                         |
                                                                         / Collector
                                                            Base        /
                    Arduino Digital Pin 8 --------\/\/\/\/--------[NPN transistor]
                                                1k resistor             \
                                                                         \ Emitter
                                                                         |
                                                                         |
                                                                         |
                                                                         +---------------- GND

jjmuteteke:
P.S. would you happen to no how to program a usb host shield

I can't comment on that - it seems a bit out of left field; why do you think you need a USB host shield for motor control (or is it in relation to another task)?

jjmuteteke:
p.s.s. would two motor controllers make it more complicated and time consuming?

The only real reason to use motor controllers (for this project) is if you need the capability to:

  1. independently control each motor
  2. independently control the speed of each motor
  3. independently control the direction of each motor

If you don't need any of those capabilities, then using one or more motor controllers will only raise the cost of the project and make it larger while causing it to draw more current; if you insist on using 9 volt batteries, larger isn't the direction you want to be headed in (for your small motors, I agree with everyone else that using a 9 volt PP3 battery is the -wrong- choice; the battery will not last long at all, and they are expensive to replace as well).

I've updated focalist's schematic to (hopefully) make it more clear how to hook things up

What no 'flywheel diode', I thought you knew better. :grin:

All four motors as Crosh has shown. Using one of the PWM outputs would even allow you to vary the speed of the motors. PWM simply turns the power off and on really fast to provide what "looks" like a variable supply to the motors. However, it makes sense to walk before you run, so stick with off and on at first. Only the software will change (and only a few lines) to add PWM speed control, the hardware stays the same.

Stick with the idea that the transistor is a valve and the arduino "turns" that valve off and on via the base of the transistor. The valve lets the current flow, which turns the motors. It's really not all that different than waterand plumbing, and people understand pipes and valves pretty well. The 9v battery works in that model too- it's got plenty of water pressure, it's just got a tiny tank.

By the same token, the digital output of the arduino doesn't have a big enough tank to run the motors either.. but it does have enough to turn a valve off and on, which can be connected to whatever water reserve you want. The "water" flowing through the "pipes" (wires) is what makes the motors turn around... and Ground is simply where it all goes down the drain. :wink:

It's a really crude analogy, but it's helped me more than once.. and starting out, demystified things quite a bit- even if a bit inaccurate for the sake of making it understandable to a neophyte..

It's really not all that different than water, and people understand pipes and valves pretty well.

Good, could you come over and solve an intermittent leak I have under my kitchen sink. Oh and bring a bright flashlight with you. :wink:

No prob, as long as the ticket is waiting at Logan. I'd love a few days in Frisco.. far too long since I've been, and I love the city. Almost as much as I like the Humboldt country and Big Sur. Heck, I find most things north and south of LA to be pretty great, just skip 100 miles on each side as a sort of quarantine, and California becomes a lot nicer place. I was born in San Diego but moved away as a young kid... Navy brat. Los Angeles is...ummm...Hmm. Gommorrah? Okay maybe that's a LITTLE overboard, but you get the sense of my feelings about that fine metropolis. I'd miss Cali if it fell into the ocean, LA not so much. I've not been to Frisco since I got back into photography.. and Frisco is one of the most picturesque cities in the world. Come to think of it, I think I might have to start ferreting away nickels and dimes. I didn't go anywhere this year, but I usually try to travel for a few days every late winter to just do photography and get away. Frisco would be a great destination.

Own a house on a fixed income, and you learn about tradeskills you never imagined you'd be doing... I can't afford a plumber or an electrician or a carpenter every time something dies or breaks. Sometime before the fall, I need to sweat a new solenoid valve, cutoff and about three feet of pipe into the heating system plumbing or I'll not have heat.. but I learned how last time one went, so this time it's just a matter of getting the parts and then having a time to do it. I tend to work in spurts when I'm feeling good, and plan/purchase during the other times so when I feel decent, I'll be looking "at" it, rather than looking "for" it, whatever it may be. I've gotten smart enough to stockpile things like PVC and Copper pipe, a small spool of 12/3 Romex, breakers and GCFI sockets in the basement on a shelf. Not a ton, just realistic amounts- I rarely buy ONE of anything, as if it broke once, it's gonna break again sometime, most likely. If I'm not Jerry-rigging one thing or another to an Arduino, I'm Jerry-rigging some appliance, device, chunk of furniture, wall covering, or family pet to avoid calling one "pro" or another... hehe. By the way, I don't suppose one can still get Ether very easily, and they want to know WHY you want to buy suture kits, whether or not it's LEGAL to buy them or not. Sometimes it's a good thing I can't get required supplies, I think.

You become a master of Duct Tape, PVC pipe (both for plumbing and for building lightweight frames and supports), Epoxies of every flavor, goops and sealants, and eventually even how to do some things right. I plumbed in our kitchen sink, all the way to the outflow including cleanouts.. and it has one of those nice pull-out-kinda-thing spouts and all that, a Boiling Water tap (neato toy I got as a gift), as well as garbage disposal and dishwasher... not a single leak in five years.. The thing is a deep-bowl double sided monster.. made of Black synthetic granite. More durable and lighter, kinda like Corian, but I forget the name. DuPont polymer something or other. Looks pretty snappy.

Heck, I find most things north and south of LA to be pretty great, just skip 100 miles on each side as a sort of quarantine, and California becomes a lot nicer place.... ...Los Angeles is...ummm...Hmm. Gommorrah? Okay maybe that's a LITTLE overboard, but you get the sense of my feelings about that fine metropolis. I'd miss Cali if it fell into the ocean, LA not so much.

For anyone having never been to California, focalist has summed up the situation as precisely as a well written Arduino sketch. California has amazing almost unlimited diversity and things you will not see anywhere else in the world (I love giant Redwood trees) but by no means should the lure of Disney Land or Universal studios sucker you into visiting LaLa land.

Lefty

retrolefty:

I've updated focalist's schematic to (hopefully) make it more clear how to hook things up

What no 'flywheel diode', I thought you knew better. :grin:

Ya know, after I posted it, I realized I should've added it - and thought I'd get some guff; sure 'nuff was right!

:grin:

There - fixed it for ya!

:slight_smile:

Yeah, but you guys are stuck with the Giants.

We have the Pats... The Bruins.. The Celtics and of course the Red Sox.
Nothing beats Fenway and a cold beer. It'll cost a fortune these days, but it's worth it once a year.

They don't always win (but often do)- but NOTHING on this PLANET is quite a New England sports fan. You guys like your teams, people LIVE AND DIE for who is on the ice for a B's game any given night. It's plain bizarre.

To be honest, the pretty new england winter gets old around the second of january, on either side is four months where sports is a reasonably good option as a timekiller to prevent cabin fever during blizzards..

focalist:
You become a master of Duct Tape, PVC pipe (both for plumbing and for building lightweight frames and supports), Epoxies of every flavor, goops and sealants, and eventually even how to do some things right. I plumbed in our kitchen sink, all the way to the outflow including cleanouts.. and it has one of those nice pull-out-kinda-thing spouts and all that, a Boiling Water tap (neato toy I got as a gift), as well as garbage disposal and dishwasher... not a single leak in five years.. The thing is a deep-bowl double sided monster.. made of Black synthetic granite. More durable and lighter, kinda like Corian, but I forget the name. DuPont polymer something or other. Looks pretty snappy.

This is the truth. I don't live on a fixed income (and if something breaks beyond my ability, I call in a pro - depending on the need, it will either be a contractor I've hired in the past, or it will be someone via my TotalProtect plan), but I have done tons of my own little home plumbing and electrical jobs. One repair or another, indoors or out. I also have a large supply of goops and sealants (favorite two: Permatex Copper silicone gasket, and JB Weld - the Permatex is great for all kinds of gaskets, whether your car or your home - and JB Weld is the same way - provided you want it as nearly permanent as possible). I've got a few lawn sprinklers I need to fix, and I have to install a new mister system in our back yard. At some point my wife and I need to replace the bathroom sinks (that may turn into a "call the expert" thing, depending on how difficult it is to remove and replace the current sink and backsplash; they're almost 40 years old now).

Part of me loves being a homeowner, another part of me wonders if it's really worth it (glad to have my shop, though!).

:slight_smile:

Yeah, but you guys are stuck with the Giants.

Oh, you mean the present WORLD CHAMPION Giants? You may kiss the ring at the left.

It was an amazing playoff run, funny I don't recall seeing the Red Sox participating? They must have misplaced the team's visa card last year?

Lefty

retrolefty:

Heck, I find most things north and south of LA to be pretty great, just skip 100 miles on each side as a sort of quarantine, and California becomes a lot nicer place.... ...Los Angeles is...ummm...Hmm. Gommorrah? Okay maybe that's a LITTLE overboard, but you get the sense of my feelings about that fine metropolis. I'd miss Cali if it fell into the ocean, LA not so much.

For anyone having never been to California, focalist has summed up the situation as precisely as a well written Arduino sketch. California has amazing almost unlimited diversity and things you will not see anywhere else in the world (I love giant Redwood trees) but by no means should the lure of Disney Land or Universal studios sucker you into visiting LaLa land.

Lefty

Northern California seems to be the saner end of Cali. California's basically nice if you avoid the southern end (though I do like the area around San Diego up thru Santa Barbara) and the middle valley area. I just wish the gun laws were more like Arizona's (well, except for the whole concealed carry into a bar - that's just a ticking time bomb, there).

The only real problem with California (if you discount the middle valley section) is how expensive it is to live there...

:slight_smile:

The only real problem with California (if you discount the middle valley section) is how expensive it is to live there...

That and our dysfunctional state government. Sometime starting in the 70s the government decided they would never be able to run out of spending other people's money. Probably something they learned back in D.C. :wink:

Lefty

Hey I wonder how he's doing with that motor thing... lol

focalist:
Hey I wonder how he's doing with that motor thing... lol

What motor thing? Oh wait..........

Hey Saturdays were made for hijacking posting threads, goes well with the beer. :wink:

True that. Kids sent off to their rooms/neutral corners and they both have something to keep them busy, so we're going over to a neighbor's house for a cool one.

Have a "thing" tomorrow, only good part is that it's on the water down the Cape Cod way for a few hours, and I might see something worth pointing a camera at. The Cape and Martha's Vineyard really are gems that few outside of New England know about-- but it's where the Presidents go on their summer vacations- guess that says SOMETHING...

The Cape and Martha's Vineyard really are gems that few outside of New England know about-- but it's where the Presidents go on their summer vacations- guess that says SOMETHING...

In the early 90s I took my wife and mother in law on a 10 day trip down to the cap, and then north, off for the fall colors all the way to upper NY and returned in a big circle route. The Mane coast remined me alot of parts of our north coast here.

The fall colors were everything they say about them. We may have bigger trees out here but you make up for it in quanity and colors in late fall. That is not a visit to miss if you haven't seen it or live there. :wink:

I do flat water kayaking when I can.. local state park lake and a meandering local river. I've made it out for paddles twice now during the "Foliage Season", a Maple in full regalia arching over a riverbank.. I'll see if I can find one of my photos. It really can be beautiful.

Maine, especially the North Coast is stunning. My wife has family up that way, outside of Bar Harbor. Last year we actually went camping for a few days in Acadia National Park, which is is on "Mount Desert Island". I am not kidding. The point is, Acadia includes Mount Cadillac, which is a huge mass of granite (leftover volcano so I am told) right on the coast. 1500 feet of pink granite in like a distance of five miles from the water, all of national park. http://www.acadiamagic.com/CadillacMountain.html

I've never posted/shown the photos I took of it anywhere publicly, but when I was there, it was bathed in fog which burned off like wisps of fire as the rising sun hit it. Not shabby shots. Several I think are superior to the ones the travel and tour companies use, in my own humble opinion :wink: The top of Mount Cadillac is the first place in the USA to see the sun every day.

I guess I should post a few of those too... I really want terribly to have even a single day of shooting in Yellowstone.... Big Sur also has that stunning scenery you'll see nowhere else. Last time I was there, I was in grade school. Having a camera just gives me an excuse to walk around and stare at nothing all day and look legitimate doing it.

I would like to thank every body for helping me you all just literally saved my life but i have one more quick question so do i use schematic by cr0tch and if i do do i need the diode? also based on the schematic i don't need to give the motors(4 of them) their own 9v battery?. also im going to go to radio shack so can i get the final schematic on wether to use the diode or not? also for the programming want to control the speed of motors so can i get the programming on that based on the PWM pin nine on the arduino duimilanove ATMEGA328.
thank you very much for your help