2015-02-24 17:56:01 -08:00
|
|
|
/*
|
|
|
|
* Author: Stan Gifford <stan@gifford.id.au>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-02-24 17:56:01 -08:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-02-24 17:56:01 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description
|
|
|
|
* Demo program for Adafruit 16 channel servo shield/controller
|
|
|
|
* Physical setup for tests is a single servo attached to one channel.
|
|
|
|
* Note - when 3 or more GWS servos attached results unpredictable.
|
2017-08-30 15:00:29 -07:00
|
|
|
* Adafruit do recommend a Cap be installed on the board which should alleviate
|
|
|
|
* the issue.
|
2015-02-24 17:56:01 -08:00
|
|
|
* I (and Adafruit) are unable to give any Capacitor sizing data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "adafruitss.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2015-02-24 17:56:01 -08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
int n;
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
|
|
|
upm::adafruitss servos(6, 0x40);
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
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
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Setting all to 45" << endl;
|
|
|
|
for (n = 0; n < 16; n++)
|
|
|
|
servos.servo(n, 1, 45);
|
|
|
|
upm_delay_us(1000000); // Wait 1 second
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Setting all to 90" << endl;
|
|
|
|
for (n = 0; n < 16; n++)
|
|
|
|
servos.servo(n, 1, 90);
|
|
|
|
upm_delay_us(1000000); // Wait 1 second
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Setting all to 135" << endl;
|
|
|
|
for (n = 0; n < 16; n++)
|
|
|
|
servos.servo(n, 1, 135);
|
|
|
|
upm_delay_us(1000000); // Wait 1 second
|
2015-02-24 17:56:01 -08:00
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
cout << "Setting all to 180" << endl;
|
|
|
|
for (n = 0; n < 16; n++)
|
|
|
|
servos.servo(n, 1, 160);
|
|
|
|
upm_delay_us(2000000); // Wait 1 second
|
|
|
|
}
|
|
|
|
//! [Interesting]
|
|
|
|
return 0;
|
2015-02-24 17:56:01 -08:00
|
|
|
}
|