Two LEDS connected on chanel 0 and 1 that change their brightness continually.

Dependencies:   PCA9685PWM mbed

main.cpp

Committer:
dreamworker
Date:
2015-07-24
Revision:
1:812d6effcc5f
Parent:
0:46968a9b2b95

File content as of revision 1:812d6effcc5f:

/*Test program for PCA9685 library
 *Two leds connected on chanel 0 and 1 that change their brightness continually
 */
#include"PCA9685.h"
#include"mbed.h"



PCA9685 pwm(D14,D15);
 
 
void initDriver() {
    pwm.begin();
    pwm.setPWMFreq(1600);     // max frequency
    pwm.frequencyI2C(400000); //400kHz fast I2C comunication
}
 
int main() {
    initDriver();
   
    while(1){
        for (int i = 0; i < 4095; i=i+8){
            pwm.setPWM(0,4095-i,0);
            wait(0.0005);
            pwm.setPWM(1,i,0);
            wait(0.0005);            
            }
        for (int i = 4094; i > 0; i=i-8){
            pwm.setPWM(0,4095-i,0);
            wait(0.0005);
            pwm.setPWM(1,i,0);
            wait(0.0005); }           
            }
        }