Paolo Sanna
/
PCA9685_with_LED
Two LEDS connected on chanel 0 and 1 that change their brightness continually.
main.cpp
- Committer:
- dreamworker
- Date:
- 2015-07-24
- Revision:
- 0:46968a9b2b95
- Child:
- 1:812d6effcc5f
File content as of revision 0:46968a9b2b95:
/*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); } } }