Servo motor works on PWM (Pulse width modulation) principle, means its angle of rotation is controlled by the duration of applied pulse to its Control PIN. Basically servo motor is made up of DC motor which is controlled by a variable resistor (potentiometer) and some gears. High speed force of DC motor is converted into torque by Gears. We know that WORK= FORCE X DISTANCE, in DC motor Force is less and distance (speed) is high and in Servo, force is High and distance is less.
-------------------
int value = 0;
int angle = 0;
void setup()
{
pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(WGM20);
TCCR2B = _BV(CS22)| _BV(CS22);
OCR2A = 255;
}
void loop()
{
value = analogRead(A0);
angle = map(value, 0, 1023, 60, 255);
OCR2A = angle;
}
reference:
pmw
No comments:
Post a Comment