Neil Thiessen
/
PCA9955_HelloWorld
A simple serial test program for the PCA9952/55 library.
main.cpp
- Committer:
- neilt6
- Date:
- 2013-11-07
- Revision:
- 1:899dbe28da72
- Parent:
- 0:6ef5b29b9e14
- Child:
- 2:3bf093141522
File content as of revision 1:899dbe28da72:
#include "mbed.h" #include "PCA9955.h" //Create an PCA9955 object at the default address (ADDRESS_0) PCA9955 driver(p28, p27); 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(); //Set all the output states to PWM mode driver.allOutputStates(PCA9955::OUTPUT_PWM); //Set the 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"); } }