GY-63_MS5611/libraries/PCA9685/examples/PCA9685_test01/PCA9685_test01.ino
RobTillaart 6f2041f470 + fixed setON() and setOFF(),
+ add setFrequency(),
+ refactor
2019-01-30 14:28:59 +01:00

78 lines
1.4 KiB
C++

//
// FILE: PCA9685_test01.ino
// AUTHOR: Rob Tillaart
// DATE: 24-APR-2016
// VERSION: 0.1.00
// PUPROSE: test PCA9685 library
//
#include "PCA9685.h"
#include <Wire.h>
PCA9685 ledArray(0x20);
void setup()
{
Wire.begin();
ledArray.begin();
Serial.begin(115200);
Serial.print("PCA9685 LIB version: ");
Serial.println(PCA9685_LIB_VERSION);
Serial.println();
testSetON();
testPWMMode();
delay(2000);
testSetOFF();
Serial.print(millis());
Serial.print("\t");
Serial.println("done...");
}
void testSetON()
{
Serial.print(millis());
Serial.print("\t");
Serial.println("Test - setON");
for (int channel = 0; channel < 16; channel++)
{
ledArray.setON(channel);
}
}
void testSetOFF()
{
Serial.print(millis());
Serial.print("\t");
Serial.println("Test - setOFF");
for (int channel = 0; channel < 16; channel++)
{
ledArray.setOFF(channel);
}
}
void testPWMMode()
{
Serial.print(millis());
Serial.print("\t");
Serial.println("Test - setPwm getPWM");
for (int channel = 0; channel < 16; channel++)
{
// every next line ~twice as much time
ledArray.setPWM(channel, channel*127, channel*255);
uint16_t a, b;
ledArray.getPWM(channel, &a, &b);
if (a != channel*127 || b != channel*255)
{
Serial.println(channel);
}
}
}
void loop()
{
}