Neil Thiessen
/
PCA9955_HelloWorld
A simple serial test program for the PCA9952/55 library.
main.cpp
- Committer:
- neilt6
- Date:
- 2014-04-08
- Revision:
- 4:0b1798094768
- Parent:
- 2:3bf093141522
- Child:
- 5:e0d366e2a7f0
File content as of revision 4:0b1798094768:
#include "mbed.h" #include "PCA9955.h" //Create a PCA9955 object using the LED All Call address PCA9955 driver(P0_5, P0_4, PCA9955::ADDRESS_ALL); int main() { //Try to open the PCA9955 if (driver.open()) { printf("Device detected!\n"); //Reset the device //NOTE: This might reset other I2C devices as well! driver.reset(); wait_ms(5); //Set all of the output states to PWM mode driver.allOutputStates(PCA9955::OUTPUT_PWM); //Set all of the output currents to maximum driver.allOutputCurrents(1.0); while (1) { //Generate a breathing effect on all of the outputs for (float i = 0.0f; i < 360.0f; i += 0.1f) { driver = 0.5 * (sinf(i * 3.14159265f / 180.0f) + 1); } } } else { error("Device not detected!\n"); } }