I'm creating a robot that has 5 motors.
I need PWM for all 5 motors. I have a arduino diecimila. What is the best way of doing this with my arduino? I know the diecimila has 3 pwm pins, but that's not enough.
The program is very simple. All it's doing is reading serial input, and changing the motor's speed according to the serial input.
There are actually 6 pwm pins on the diecimila, pins 3,5,6,8,9 and 10. So that aspect shouldn't be a problem. However, you will probably need some sort of driver circuitry to actually be able to control the motors because the Arduino pins can only source 40 milliamps.
I haven't tried one yet, though. I bought one of their I2C LCD controllers, and am moderately impressed with it: it's well-made, inexpensive, and has a well-thought-out feature set. The reason I'm only saying "moderately" is that the documentation looks good, but doesn't fully reveal or explain some of its quirks (most notably, only some of the cases where you need to give it some time to execute commands are identified). I'm having to uncover some of those quirks by experimentation.
But I'm impressed enough that I'd buy one of their chips to try out if I had a lot of servos to control, and will probably pick up one to play with for its other features.
I tried it out, downloaded the libraries, put the unziped Servo folder into arduino-0015/hardware/libraries, and replaced the old Servo folder (i kept a backup)
I ran the demo software and it couldn't compile. This error appeared.
In file included from F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware\cores\arduino/WProgram.h:4,
f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
In file included from F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware\cores\arduino/WProgram.h:6,
Servo.cpp: In member function 'uint8_t Servo::attach(int)':
Servo.cpp:28: error: 'digitalWrite' was not declared in this scope
Servo.cpp:29: error: 'OUTPUT' was not declared in this scope
Servo.cpp:29: error: 'pinMode' was not declared in this scope
Servo.cpp: In member function 'void Servo::write(int)':
Servo.cpp:52: error: 'clockCyclesPerMicrosecond' was not declared in this scope
Servo.cpp: In static member function 'static void Servo::refresh()':
Servo.cpp:74: error: 'millis' was not declared in this scope
Servo.cpp:107: error: 'digitalWrite' was not declared in this scope
Servo.cpp:109: error: 'TCNT0' was not declared in this scope
Servo.cpp:124: error: 'digitalWrite' was not declared in this scope
o: In function `__static_initialization_and_destruction_0':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:6: undefined reference to `Servo::Servo()'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:7: undefined reference to `Servo::Servo()'
o: In function `loop':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:34: undefined reference to `Servo::write(int)'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:38: undefined reference to `Servo::detach()'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:41: undefined reference to `Servo::attach(int)'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:46: undefined reference to `Servo::refresh()'
o: In function `setup':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:11: undefined reference to `Servo::attach(int)'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:12: undefined reference to `Servo::setMaximumPulse(unsigned int)'
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:13: undefined reference to `Servo::attach(int)'
Couldn't determine program size: F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware/tools/avr/bin/avr-size: 'F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex': No such file
avrdude: can't open input file F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex: No such file or directory
avrdude: write to file 'F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex' failed
Some Arduino definitions were added in release 0012 that conflict with the core language if they are included in a library header file. This is generally only an issue with older libraries and is easily fixed once you know how.