NavigationUser login |
Reply to commenttor - Sat, 08/02/2008 - 19:33
One of the easiest way of testing PWM (Pulse Width Modulation) for regulating power on electric motors, such as fans, is to attach a standard LED to the Arduino. Put the short pin of the LED into the socket marked PWN 13 on the digital side of the board, and the other pin into the socket marked GND. Run the following little program (called a Sketch) on the Arduino. // PWM test using a LED // connected between one of the PWM pins // - and ground - use the short pin to ground int ledvalue = 0; // variable to keep the pwn duty cycle value int ledpin = 9; // light connected to pwm pin int stepsize = 1; // how many steps to increase the duty cycle with per stepdelay int stepdelay = 20; // The delay (millisecs) between increases/decreases in duty cycle int ledmin = 10; // minimum value for duty cycle int ledmax = 255; // maximum value for duty cyclevoid setup() { } void loop() { for(ledvalue = ledmin ; ledvalue <= ledmax; ledvalue+=stepsize) // increase duty cycle (from min to max) { analogWrite(ledpin, ledvalue); // sets the value from ledmin to ledmax delay(stepdelay); // waits for stepdelay milliseconds to make sure we can observe this } for(ledvalue = ledmax; ledvalue >=ledmin; ledvalue-=stepsize) // reduce duty cycle (from max to min) { analogWrite(ledpin, ledvalue); delay(stepdelay); } } And you can see the brightness of the LED change. But these pins on the Arduino can only supply a little bit of current, so to support a real motor we will need to use a few more components to drive these - more about this later. Blog reactionsNo reactions yet. Technorati Tags: Trackback URL for this post:http://www.gisvold.co.uk/~gisvold/drupal/trackback/1315
Reply |
BuzzworthySearchPostings on BrightkiteWeblinksNot yet implemented.
|