This example is for Wiring version 1.0 build 0100+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.
Driving a DC cell phone vibrating motor. by Diana Fernandez
Demonstrates the use of a vibrating DC motor (cell phone motor). On Wiring v1 boards the PWM capable pins are: 29, 30, 31, 35, 36 and 37 On Wiring S board the PWM capable pins are: 4, 5, 6, 7, 19 and 20
int motorpin = 4; // Vibrating motor connected to pin PWM 4voidsetup()
{
pinMode(motorpin, OUTPUT);
}
voidloop()
{
analogWrite(motorpin, 125); // turn ON the Motor at medium speeddelay(100);
}