PCA9635 16-bit I2C-bus LED driver
Dependents: digitalThermometer Counter SimpleClock printNumber ... more
PCA9635 Class Reference
PCA9635 class defined on an I2C master bus. More...
#include <PCA9635.h>
Public Member Functions | |
PCA9635 (PinName sda, PinName scl) | |
Create a PCA9635 object, connected to the specified I2C pins. | |
void | on (char led) |
Set a particular output on PCA9635 high. | |
void | off (char led) |
Reset a particular output on PCA9635 low. | |
void | bus (short leds) |
Set all pins passed as argument high or low for current address. | |
void | brightness (char led, char value) |
Set all pins passed as argument high or low for specified address. | |
void | setAddress (int address) |
Set write address. | |
void | reset (void) |
Reset chip. | |
void | init (int address) |
Initialise chip - MUST call this before calling any other functions. |
Detailed Description
PCA9635 class defined on an I2C master bus.
Example:
//Turn each output on and then off in order p0 >> p15 //then ramp brightenss up and down at different speeds. #include "mbed.h" #include "PCA9635.h" DigitalOut enable(p26); PCA9635 my_driver(p28, p27); int main() { enable = 0; my_driver.init(0x02); //N.B. you MUST declare init(int address), before calling any PCA9635 functions //turns each pin on and then off short op = 1; for(char j = 0; j < 16; j++){ my_driver.bus(op); wait(0.7); op = (op << 1); } //ramp brightness up three times faster than down, repeatedly while(1) { for(char valueUp=0; valueUp<0xFF; (valueUp = valueUp + 3)) { my_driver.brightness(ALL, valueUp); } for(char valueD=0; valueD<0xFF; valueD++) { my_driver.brightness(ALL, (0xFF - valueD)); wait(0.007); } } }
Definition at line 56 of file PCA9635.h.
Constructor & Destructor Documentation
PCA9635 | ( | PinName | sda, |
PinName | scl | ||
) |
Create a PCA9635 object, connected to the specified I2C pins.
- Parameters:
-
sda Defines serial data line scl Defines serial clock line
Definition at line 9 of file PCA9635.cpp.
Member Function Documentation
void brightness | ( | char | led, |
char | value | ||
) |
Set all pins passed as argument high or low for specified address.
- Parameters:
-
led Pin co-ordinates value Brightness value
Definition at line 87 of file PCA9635.cpp.
void bus | ( | short | leds ) |
Set all pins passed as argument high or low for current address.
- Parameters:
-
leds Set output according to parameter value - e.g. 0x0003 >> p0 & p1 high, rest low
Definition at line 72 of file PCA9635.cpp.
void init | ( | int | address ) |
Initialise chip - MUST call this before calling any other functions.
- Parameters:
-
address hardware address
Definition at line 26 of file PCA9635.cpp.
void off | ( | char | led ) |
Reset a particular output on PCA9635 low.
- Parameters:
-
led LED pin coordinates
Definition at line 64 of file PCA9635.cpp.
void on | ( | char | led ) |
Set a particular output on PCA9635 high.
- Parameters:
-
led LED pin coordinates
Definition at line 55 of file PCA9635.cpp.
void reset | ( | void | ) |
Reset chip.
Definition at line 16 of file PCA9635.cpp.
void setAddress | ( | int | address ) |
Generated on Tue Jul 19 2022 03:54:59 by 1.7.2