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

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.

/media/uploads/nxp_ip/anm.gif

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.

wiring

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

Component page is available

Please refer to the component page for for more information.

I2C 8x8 LED matrix board" from Switch Science

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/

6 boards operation sample is also available.
This program controls 6 modules independently.

Import programPCA9622_LED8x8_x6_Demo

Sample code to operate 6 of PCA9622_LED8x8 module



Committer:
nxp_ip
Date:
Thu Feb 26 00:08:25 2015 +0000
Revision:
3:9ee3a0cfa2b7
Parent:
2:aaa5b046e49d
Version with latest library "PCA9622_LED8x8 v1.1.1"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:ac9e3a1bbc8f 1 /**
nxp_ip 0:ac9e3a1bbc8f 2 * A hello world code for the PCA9622 LED 8x8 library
nxp_ip 0:ac9e3a1bbc8f 3 *
nxp_ip 0:ac9e3a1bbc8f 4 * @author Tedd OKANO
nxp_ip 2:aaa5b046e49d 5 * @version 1.1
nxp_ip 2:aaa5b046e49d 6 * @date 25-Dec-2014
nxp_ip 0:ac9e3a1bbc8f 7 *
nxp_ip 0:ac9e3a1bbc8f 8 * This is a very simple sample code for the PCA9622_LED8x8 library.
nxp_ip 0:ac9e3a1bbc8f 9 * Target hardware : "I2C 8x8 LED matrix board" from Switch Science
nxp_ip 0:ac9e3a1bbc8f 10 * https://www.switch-science.com/catalog/2071/
nxp_ip 0:ac9e3a1bbc8f 11 *
nxp_ip 0:ac9e3a1bbc8f 12 * The I2C LED controller PCA9622 is used on this module
nxp_ip 0:ac9e3a1bbc8f 13 * that ebables to control the LEDs with PWM brightness control.
nxp_ip 0:ac9e3a1bbc8f 14 *
nxp_ip 0:ac9e3a1bbc8f 15 * For more information about the PCA9622:
nxp_ip 0:ac9e3a1bbc8f 16 * http://www.nxp.com/documents/data_sheet/PCA9622.pdf
nxp_ip 0:ac9e3a1bbc8f 17 */
nxp_ip 0:ac9e3a1bbc8f 18
nxp_ip 0:ac9e3a1bbc8f 19 #include "mbed.h"
nxp_ip 0:ac9e3a1bbc8f 20 #include "PCA9622_LED8x8.h"
nxp_ip 0:ac9e3a1bbc8f 21
nxp_ip 0:ac9e3a1bbc8f 22 // Choose a target platform from next list
nxp_ip 0:ac9e3a1bbc8f 23 PCA9622_LED8x8 matrix( p28, p27 ); // for 40pin type mbed
nxp_ip 0:ac9e3a1bbc8f 24 //PCA9622_LED8x8 matrix( D14, D15 ); // for Arduino type mbed
nxp_ip 0:ac9e3a1bbc8f 25 //PCA9622_LED8x8 matrix( dp5, dp27 ); // for mbed LPC1114
nxp_ip 0:ac9e3a1bbc8f 26
nxp_ip 0:ac9e3a1bbc8f 27 float func( float x, float y, float t ); // function to make 8x8 image
nxp_ip 0:ac9e3a1bbc8f 28
nxp_ip 0:ac9e3a1bbc8f 29 int main()
nxp_ip 0:ac9e3a1bbc8f 30 {
nxp_ip 0:ac9e3a1bbc8f 31 float image[ 8 ][ 8 ]; //
nxp_ip 0:ac9e3a1bbc8f 32 int count = 0;
nxp_ip 0:ac9e3a1bbc8f 33
nxp_ip 0:ac9e3a1bbc8f 34 while(1) {
nxp_ip 0:ac9e3a1bbc8f 35
nxp_ip 0:ac9e3a1bbc8f 36 // making 8x8 image to "image" array
nxp_ip 0:ac9e3a1bbc8f 37 for ( int i = 0; i < 8; i++ )
nxp_ip 0:ac9e3a1bbc8f 38 for ( int j = 0; j < 8; j++ )
nxp_ip 0:ac9e3a1bbc8f 39 image[ i ][ j ] = func( i, j, count * 0.2 );
nxp_ip 0:ac9e3a1bbc8f 40
nxp_ip 0:ac9e3a1bbc8f 41 // set the image into library internal bufer
nxp_ip 0:ac9e3a1bbc8f 42 matrix.set_data( image );
nxp_ip 0:ac9e3a1bbc8f 43
nxp_ip 0:ac9e3a1bbc8f 44 count++;
nxp_ip 0:ac9e3a1bbc8f 45 wait( 0.05 );
nxp_ip 0:ac9e3a1bbc8f 46 }
nxp_ip 0:ac9e3a1bbc8f 47 }
nxp_ip 0:ac9e3a1bbc8f 48
nxp_ip 0:ac9e3a1bbc8f 49 float func( float x, float y, float t )
nxp_ip 0:ac9e3a1bbc8f 50 {
nxp_ip 0:ac9e3a1bbc8f 51 //#define DISPLAY_OFFSET 3.5
nxp_ip 0:ac9e3a1bbc8f 52 #define DISPLAY_OFFSET 0
nxp_ip 0:ac9e3a1bbc8f 53 #define SIZE 0.3
nxp_ip 0:ac9e3a1bbc8f 54
nxp_ip 0:ac9e3a1bbc8f 55 float s;
nxp_ip 0:ac9e3a1bbc8f 56
nxp_ip 0:ac9e3a1bbc8f 57 x = (x - DISPLAY_OFFSET) * SIZE;
nxp_ip 0:ac9e3a1bbc8f 58 y = (y - DISPLAY_OFFSET) * SIZE;
nxp_ip 0:ac9e3a1bbc8f 59
nxp_ip 0:ac9e3a1bbc8f 60 s = cos( powf( x * x + y * y, 0.5 ) - t );
nxp_ip 0:ac9e3a1bbc8f 61 return ( powf( s, 4.0 ) );
nxp_ip 0:ac9e3a1bbc8f 62 }