![](/media/cache/profiles/a53d1388191884b75c48bebb18709bfb.50x50_q85.jpg)
This is a very simple sample code for the PCA9622_LED8x8 library. arget hardware : "I2C 8x8 LED matrix board" from Switch Science https://www.switch-science.com/catalog/2071/
Dependencies: PCA9622_LED8x8 mbed
You are viewing an older revision! See the latest version
Homepage
0. What is this?¶
Demo sample code for PCA9622_LED8x8 library.
The PCA9622_LED8x8 is a driver for "I2C 8x8 LED matrix board" from Switch Science". This code will show the wave of the brightness on 8x8 LED array.
Import libraryPCA9622_LED8x8
Library for "I2C 8x8 LED matrix board" from Switch Science https://www.switch-science.com/catalog/2071/
This animation is made by mbed internal calculation.
1. How to use¶
Hardware¶
Need to connect 4 wires only.
3.3V supply, GND, and I2C signal lines (SDA, SCL)
This LED matrix board has 10kΩ pull-up resisters on both SDA and SCL. So user don't nee to put those.
1.2 Software¶
1.2.1 Before compiling¶
Just import this program and run on mbed.
Before compiling, set the PinName for your mbed.
PCA9622_LED8x8 matrix( p28, p27 ); // for 40pin type mbed //PCA9622_LED8x8 matrix( D14, D15 ); // for Arduino type mbed //PCA9622_LED8x8 matrix( dp5, dp27 ); // for mbed LPC1114
This code was tested on mbed LPC1768, mbed LPC11U24, mbed LPC1114FN28, TG-LPC11U35-501, mbed LPC1549, LPCXpresso824-MAX.
1.2.2 Customising¶
Modifying func() function will give different behavior of brightness pattern.
#include "mbed.h" #include "PCA9622_LED8x8.h" // Choose a target platform from next list PCA9622_LED8x8 matrix( p28, p27 ); // for 40pin type mbed //PCA9622_LED8x8 matrix( D14, D15 ); // for Arduino type mbed //PCA9622_LED8x8 matrix( dp5, dp27 ); // for mbed LPC1114 float func( float x, float y, float t ); // function to make 8x8 image int main() { float image[ 8 ][ 8 ]; // int count = 0; matrix.start(); while(1) { // making 8x8 image to "image" array for ( int i = 0; i < 8; i++ ) for ( int j = 0; j < 8; j++ ) image[ i ][ j ] = func( i, j, count * 0.2 ); // set the image into library internal bufer matrix.set_data( image ); count++; wait( 0.05 ); } } float func( float x, float y, float t ) { //#define DISPLAY_OFFSET 3.5 #define DISPLAY_OFFSET 0 #define SIZE 0.3 float s; x = (x - DISPLAY_OFFSET) * SIZE; y = (y - DISPLAY_OFFSET) * SIZE; s = cos( powf( x * x + y * y, 0.5 ) - t ); return ( powf( s, 4.0 ) ); }
2. Reference¶
For more information, please find library page and Components page
For demo purpose, there is a program with some LED image patterns. The demo program is available as "PCA9622_LED8x8_Demo".
Import programPCA9622_LED8x8_Demo
This is a simple demo code for the PCA9622_LED8x8 library. arget hardware : "I2C 8x8 LED matrix board" from Switch Science https://www.switch-science.com/catalog/2071/