Servo.setMinimumPulse

From Pinguino
Jump to: navigation, search

Name

servo.setMinimumPulse

Description

This function sets the minimum pulse width allowed for the servo specified (That minimum pulse width commonly is equal to 0 degrees position).

Since
Beta 32X, releasee 323.
Warning!
Servo library uses PIC's Timer1 (TMR1). So, be aware of that in case you plan to use a timer in your application. Otherwise you could disrupt servo library.

Syntax

 servo.setMinimumPulse(pin,pulsewidth);
pin 
Value: Check valid values according to board : [Servo library supported boards ]
Argument type: unsigned char
pulsewidth 
value in microseconds, allowed values must be greater than 500 microseconds.
Argument type: integer
Output
None

Example

The following example defines pin 8 as servo driver.

In the loop(), position of servo(pin 8) will be alternated from 180 to 0 degrees positions every 2 seconds.

Connectivity diagram is shown within the code comments.

// Servo library test with Pinguino
// Connect servo control lines to pinguino pins.
// Feed servos with +5 V:
//
//   +-----+
//   |servo|--------- PWM Servo control ---> to pinguino pin.
//   |     |--------- +5V
//   |  o  |--------- GND
//   |     | 
//   +-----+


void setup(void)
{
servo.attach(8);
servo.setMaximumPulse(8,2200);
servo.setMinimumPulse(8,700);
}

//The following routine just alternate positions from 0 to 180 degrees every 2 seconds.
void loop(void)
{
delay(2000);
servo.write(8,180);
delay(2000);
servo.write(8,0);
}

Bugs

See also

servo.attach

servo.detach

servo.write

servo.read

servo.setMaximumPulse

Comments