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

Dependencies:   PCA9955 mbed

Committer:
neilt6
Date:
Fri Nov 08 16:34:50 2013 +0000
Revision:
2:3bf093141522
Parent:
1:899dbe28da72
Child:
4:0b1798094768
Updated to demonstrate the LED All Call address

Who changed what in which revision?

UserRevisionLine numberNew contents of line
neilt6 0:6ef5b29b9e14 1 #include "mbed.h"
neilt6 0:6ef5b29b9e14 2 #include "PCA9955.h"
neilt6 0:6ef5b29b9e14 3
neilt6 2:3bf093141522 4 //Create a PCA9955 object using the LED All Call address
neilt6 2:3bf093141522 5 PCA9955 driver(p28, p27, PCA9955::ADDRESS_ALL);
neilt6 0:6ef5b29b9e14 6
neilt6 0:6ef5b29b9e14 7 int main()
neilt6 0:6ef5b29b9e14 8 {
neilt6 0:6ef5b29b9e14 9 //Try to open the PCA9955
neilt6 0:6ef5b29b9e14 10 if (driver.open()) {
neilt6 0:6ef5b29b9e14 11 printf("Device detected!\n");
neilt6 0:6ef5b29b9e14 12
neilt6 0:6ef5b29b9e14 13 //Reset the device
neilt6 0:6ef5b29b9e14 14 //NOTE: This might reset other I2C devices as well!
neilt6 0:6ef5b29b9e14 15 driver.reset();
neilt6 0:6ef5b29b9e14 16
neilt6 2:3bf093141522 17 //Set all of the output states to PWM mode
neilt6 0:6ef5b29b9e14 18 driver.allOutputStates(PCA9955::OUTPUT_PWM);
neilt6 0:6ef5b29b9e14 19
neilt6 2:3bf093141522 20 //Set all of the output currents to maximum
neilt6 0:6ef5b29b9e14 21 driver.allOutputCurrents(1.0);
neilt6 0:6ef5b29b9e14 22
neilt6 0:6ef5b29b9e14 23 while (1) {
neilt6 0:6ef5b29b9e14 24 //Generate a breathing effect on all of the outputs
neilt6 0:6ef5b29b9e14 25 for (float i = 0.0f; i < 360.0f; i += 0.1f) {
neilt6 1:899dbe28da72 26 driver = 0.5 * (sinf(i * 3.14159265f / 180.0f) + 1);
neilt6 0:6ef5b29b9e14 27 }
neilt6 0:6ef5b29b9e14 28 }
neilt6 0:6ef5b29b9e14 29 } else {
neilt6 0:6ef5b29b9e14 30 error("Device not detected!\n");
neilt6 0:6ef5b29b9e14 31 }
neilt6 0:6ef5b29b9e14 32 }