A simple serial test program for the PCA9952/55 library.

Dependencies:   PCA9955 mbed

Revision:
0:6ef5b29b9e14
Child:
1:899dbe28da72
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 05 21:17:23 2013 +0000
@@ -0,0 +1,32 @@
+#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.allOutputDuties(0.5 * (sinf(i * 3.14159265f / 180.0f) + 1));
+            }
+        }
+    } else {
+        error("Device not detected!\n");
+    }
+}