brand new to arduino and programming in general. I'm trying to use some DC motors and control the rate of speed, be able to slow down and speed up as well stay steadily at different speeds. I set up allready a 9 volt motor with an external power supply, got it working with the transistor and diode. Have gotten the examples like 'blink' and fading to work---but, i'm totally unclear on how to mix these different techniques together in code. I've tried some pretty sad methods of cut and paste from the examples and keep getting all sorts of errors--is anyone willing to help a fool over here with some suggestions or examples?
Also a more general question. Any thoughts on how I would hook more then 1 motors up to do independant but precise timings? how many could I hook up to 1 duelmilanove board? If i chose to use 1 motor per arduino board would a simple on and off switch for the whole set up allign the different motors together--?
Anyways thanks so much and sorry for the long winded note--This is all very exciting to me!
You are on the right track. You have a functional 9vdc motor being switched by a transistor. Now you only need to wire the transistor base (through a series resistor) to an Arduino digital output pin that supports PWM control. You will use analogWrite() commands and there are six avalible pins on a standard 328 type Arduino board. To run six motors on one Arduino you would have to make sure your external +9vdc power source has the current capacity to run all six motors.
The rest is all learning the Arduino C/C++ programming language to control what you want the motors to do and when. It's not likely you are going to be able to cut and paste an existing sketch that does exactly what you want to do. So get to learning about programming.
thanks for all the help---yah that was a pretty cheap try huh? I've got it going now with this type of programming on pwm (at least started too..)--any suggestions on where to look for how to order multiple events at once for example
As long as a pin has pwm you can control the speed of a motor. I use h bridges for my motors... So if the motor is bi directional, you could use 2 pins (one pin goes right, one pin goes left at desired speed 0-255). I made a laser spirograph using 3 motors and one h bridge for one direction. I could have used another h bridge and had all 3 going in either right or left. If I could find my post I'd link it. You can use analog sensors like pots to read a certain value and tell the motor or motors what to do.