This method will make the DC motor "think" it is being powered by a variable voltage source between 0 and 5V, depending on the state of the potentiometer.
So, the following hardware connections should be made:
- ULN2003 PIN 8 to GND
- ULN2003 PIN 9 to 5V
- ULN2003 PIN 1 to Arduino digital control pin 9
- ULN2003 PIN 16 to one terminal of the motor
- the other terminal of the motor to 5V
- one of the outer legs of the potentiometer to 5V
- the other outer leg of the potentiometer to GND
- the middle leg of the potentiometer to Arduino analog in 0
Arduino Code:
byte data;
void setup() {
}
void loop () {
data = analogRead(0) / 4;
analogWrite(9, data);
delay(5);
}
5 comments:
I started looking into PWM about 4 or so months back, but based on a 555. I wasn't interested in controlling the speed of a motor but being able to change the %Duty Cycle of a square wave tone without, of course, changing the frequency. Once I start back on designing my synth I'll definitely include some PWM in the end product to have some on board variable chorus-like effects.
yeah for sure. picaxe has some more extensive PWM commands than the arduino, and there are also some interesting ways of having a simple dipswitch interface for controlling the % duty cycle (see here for example: http://milkcrate.com.au/_other/sea-moss/#81)
Nice. I experiment using a pot [see: http://www.cpemma.co.uk/pwm.html] on the output to vary the PWM. When I get into it I'll be making posts about it... but I doubt that'll be soon.
cooly cooly.
Pretty worthwhile info, thank you for the article.
Post a Comment