Paolo Sanna
/
PCA9685_with_LED
Two LEDS connected on chanel 0 and 1 that change their brightness continually.
Diff: main.cpp
- Revision:
- 0:46968a9b2b95
- Child:
- 1:812d6effcc5f
diff -r 000000000000 -r 46968a9b2b95 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 24 09:47:57 2015 +0000 @@ -0,0 +1,34 @@ +/*Test program for PCA9685 library + *Two leds connect 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); } + } + } \ No newline at end of file