upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the Adafruit Servo Shield. More...

Detailed Description

UPM library for the PCA9685-based Adafruit 16-channel servo shield. If 3 or more GWS servos are attached, results could be unpredictable. Adafruit Industries recommend installing a capacitor on the board, which should alleviate the issue. Sizing depends on servos and their number.

adafruitss.jpg
upm::adafruitss servos(6, 0x40);
for (;;) {
cout << "Setting all to 0" << endl;
for (n = 0; n < 16; n++)
servos.servo(n, 1, 0); // GWS Mini Servo = Type 1.
upm_delay_us(1000000); // Wait 1 second
cout << "Setting all to 45" << endl;
for (n = 0; n < 16; n++)
servos.servo(n, 1, 45);
upm_delay_us(1000000); // Wait 1 second
cout << "Setting all to 90" << endl;
for (n = 0; n < 16; n++)
servos.servo(n, 1, 90);
upm_delay_us(1000000); // Wait 1 second
cout << "Setting all to 135" << endl;
for (n = 0; n < 16; n++)
servos.servo(n, 1, 135);
upm_delay_us(1000000); // Wait 1 second
cout << "Setting all to 180" << endl;
for (n = 0; n < 16; n++)
servos.servo(n, 1, 160);
upm_delay_us(2000000); // Wait 1 second
}

Public Member Functions

 adafruitss (int bus, int i2c_address)
 
int update (void)
 
void setPWMFreq (float freq)
 
void servo (uint8_t port, uint8_t servo_type, float degrees)
 

Constructor & Destructor Documentation

adafruitss ( int  bus,
int  i2c_address 
)

Creates an adafruitss object

Parameters
busNumber of the used I2C bus
i2c_addressAddress of the servo shield on the I2C bus

Here is the call graph for this function:

Member Function Documentation

void setPWMFreq ( float  freq)

Sets the frequency of the servos

Parameters
freqFrequency at which the servos operate

Here is the caller graph for this function:

void servo ( uint8_t  port,
uint8_t  servo_type,
float  degrees 
)

Moves one of the servos to a specified angle

Parameters
portPort of the servo on the shield (servo number)
servo_typeCan be 0 = standard (1ms to 2ms), 1 = extended (0.6ms to 2.4ms), or 2 = extended (0.8ms to 2.2ms)
degreesAngle to set the servo to

The documentation for this class was generated from the following files: