HCDotMatrix Arduino library for 8x8 LED dot matrix module

Useful guides, libraries, and example sketches to support our Arduino based products.
admin
Site Admin
Posts: 865
Joined: Sun Aug 05, 2012 4:02 pm

HCDotMatrix Arduino library for 8x8 LED dot matrix module

Post by admin » Thu Oct 24, 2013 3:37 pm

Image




Library for driving 8x8 LED dot matrix modules. This Arduino library was written
to support the following Hobby Components product(s):

8x8 Red LED Matrix Module (HCOPTO0011)
8x8 Mini 20mm 8x8 Red LED Matrix (HCOPTO0067)


REVISIONS:

05/09/17 V2.0: New version - complete rewrite of previous version.
Now refreshes the screen in the background using timer interrupt 2.
UpdateMatrix() function removed as no longer required.
Added init() function (must be run once at beginning of sketch).
print() function now supports printing of floating point numbers.
Added printChar() function allowing printing of single ASCII characters.
Added clear() function to clear the module buffer and display.
Added setLED() function to turn on an individual LED from an X/Y coordinate.
Added clearLED() function to turn off an individual LED from an X/Y coordinate.
Added getLED() function to get the current state of one of the modules LEDs.
Added invert() function to reverse the state of the LEDs.


19/09/13 Created version 0.1



You will need to download (please log in to download the library) and unzip this library to the Arduino development environments library area.

On Windows:
My Documents\Arduino\libraries\

On Mac:
Documents/Arduino/libraries/

Linux:
Usually found within the users home area under /Arduino/libraries/



Using the HCDotMatrix library

To use the library just include the HCDotMatrix.h header file and create an instance of the HCDotMatrix library. E.g:

Code: Select all

#include "HCDotMatrix.h"
HCDotMatrix HCDotMatrix(R0,R1,R2,R3,R4,R5,R6,R7,C0,C1,C2,C3,C4,C5,C6,C7);
Where R0 to R7 are the digital IO pins connected to the modules 8 row pins and C0 to C7 are the digital IO pins used to connect to the modules 8 column pins.

To initialise the library add the following line to the setup() section of your sketch:

Code: Select all

HCDotMatrix.init(Module_Type);
Where module type specifies which type of module you are using and must be either:
COMMON_CATHODE
COMMON_ANODE



The following functions are available with this library:


void print(char TextString[], unsigned int Offset);

Prints a string of text to the module starting at a specified column position where:
TextString[] is a character array containing the text to print.

Offset is the column position from where the text will start from. Valid values are from 0 to 65535 (Uno/Nano etc) where:
1 = right most column
8 = left most column

Values above 8 will start the text at a column beyond the left most column.

Example:

Code: Select all

for(byte Column = 0; Column < 168; Column++)
{
    HCDotMatrix.clear();
    HCDotMatrix.print("HobbyComponents.com", Column);
    delay(50);
}



void print(float Value, unsigned int Offset = 8, byte DP = 2);

Prints a floating point number to the module starting at a specified position where:
Value is the number to print.

Offset (optional) is the column position from where the value will start from. Valid values are from 0 to 65535 (Uno/Nano etc) where:
1 = right most column
8 = left most column

Values above 8 will start the text at a column beyond the left most column.

DP (optional) specifies the number of decimal places to display a floating point number to.


Example:

Code: Select all

for(byte Number = 0; Number <= 9; Number++)
  {
    HCDotMatrix.print(Number);
    delay(1000);
  }



void printChar(char Character, byte Offset = 8);

Prints a single ASCII character to the module starting at a specified position where:
Character is the ASCII character to print.

Offset (optional) is the column position from where the character will start from. Valid values are from 0 to 65535 (Uno/Nano etc) where:
1 = right most column
8 = left most column

Values above 8 will start the text at a column beyond the left most column.

Example:

Code: Select all

HCDotMatrix.printChar('A');



void clear(void);

Clears any data in the module buffer therefore turning off all LEDs on the module.

Example:

Code: Select all

HCDotMatrix.clear();



void setLED(byte X, byte Y);

Tuns on an LED at the specified X & Y coordinate where:
X is the column coordinate (0 = left most & 7 = right most column)
Y is the row coordinate (0 = top row & 7 = bottom row)

Example:

Code: Select all

HCDotMatrix.setLED(0, 0);



void clearLED(byte X, byte Y);

Tuns off an LED at the specified X & Y coordinate where:
X is the column coordinate (0 = left most & 7 = right most column)
Y is the row coordinate (0 = top row & 7 = bottom row)

Example:

Code: Select all

HCDotMatrix.clearLED(0, 0);



boolean getLED(byte X, byte Y);

Gets the state of an LED at the specified X & Y coordinate where:
X is the column coordinate (0 = left most & 7 = right most column)
Y is the row coordinate (0 = top row & 7 = bottom row)

Returns a boolean true/false value representing the on/off state of the LED.

Example:

Code: Select all

boolean State = HCDotMatrix.getLED(0, 0);



void invert(void);
Inverts the on/off state of the LEDs

Example:

Code: Select all

boolean State = HCDotMatrix.invert();


Image

Code: Select all

// DIO pins used to drive module. Change the pin numbers to match your connections
#define ROW1  2    
#define ROW2  9    
#define ROW3  17    
#define ROW4  3   
#define ROW5  10 
#define ROW6  16
#define ROW7  11 
#define ROW8  12

#define COL1  6
#define COL2  13
#define COL3  14
#define COL4  4 
#define COL5  15
#define COL6  5
#define COL7  7
#define COL8  8


#include "HCDotMatrix.h"

HCDotMatrix HCDotMatrix(ROW1,ROW2,ROW3,ROW4,ROW5,ROW6,ROW7,ROW8,  
                        COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8);

void setup() 
{
  //Initialise the library. If your module is a common anode type then change 
  //COMMON_CATHODE to COMMON_ANODE
  HCDotMatrix.init(COMMON_CATHODE);
}


void loop() 
{
  //Display numbers 0 to 9
  for(byte Number = 0; Number <= 9; Number++)
  {
    HCDotMatrix.print(Number);
    delay(1000);
  }

  delay(1000);


  //Flash the display using the invert() library function
  for(byte i = 0; i < 20; i++)
  {
    HCDotMatrix.invert();
    delay(100);
  }


  //Scroll some text.
  for(byte Column = 0; Column < 168; Column++)
  {
    HCDotMatrix.clear();
    HCDotMatrix.print("HobbyComponents.com", Column);
    delay(50);
  }

  delay(1000);
}


Image

Version 2.0:
HCDotMatrix_V2_0.zip

Old version 0.1:
HCDotMatrix.zip

Diagrams, libraries, and example code are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

kukot
Posts: 1
Joined: Fri Aug 29, 2014 5:13 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by kukot » Fri Aug 29, 2014 5:23 pm

I can't make this work :S

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by andrew » Sat Aug 30, 2014 1:41 pm

Do you mean you can't compile the software or you are not seeing anything on the dot matrix module?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

boo
Posts: 1
Joined: Sat Apr 04, 2015 3:40 am

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by boo » Sun Apr 05, 2015 6:20 pm

Some problem in schematic and I have the inverted module. So I edit constructor in cpp to add appropriate variable also

tom
Posts: 3
Joined: Tue Apr 14, 2015 9:00 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by tom » Tue Apr 14, 2015 9:53 pm

got issues as well so in a desperate attempt i went in with a multimeter and i now have a completely different pinout will post it as soon as i'm home
altough i now can manually light up any led i want by applying power to the appropriate pins the library and examples will not work for me instead every led on the module lights up and simply stays lit :cry: want it to display some text for electronic music box im making for my wife

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by andrew » Wed Apr 15, 2015 7:36 am

Could either if you confirm that you are using the LED module that came with either the Experimenters or Master kit? If so I'll take a look at the library and see if I can fix it.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

tom
Posts: 3
Joined: Tue Apr 14, 2015 9:00 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by tom » Wed Apr 15, 2015 1:03 pm

Hi Andrew ,
I have taken a look at my order history and indeed it is an 1588BS display from the experimenters kit.
I have made some progress and can now based on the blink sketch control the columns and make them scroll.
As promised in previous post i give the pinout as i have found it
This pinout has the following orientation
1588BS text to the left with the 1 on the top
the right hand side contains pin 9 to 16 beginning from the top

Matrix pin control element Arduino
1 C4 D8
2 C2 D12
3 R2 D4
4 R3 A0
5 C1 D5
6 R5 D10
7 C3 D13
8 C6 D7
9 R8 A3
10 R7 D11
11 C7 D3
12 R1 D9
13 C5 A2
14 R6 A1
15 R4 D6
16 C8 D2


I could post the scrolling sketch i've made if requested

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by andrew » Wed Apr 15, 2015 4:11 pm

Thanks for confirming and the info. I'll take a look at the library. Please bear with me though because I'll probably have to wire one up first. I'll post back here I figure out a fix for it.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

tom
Posts: 3
Joined: Tue Apr 14, 2015 9:00 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by tom » Fri Apr 17, 2015 6:22 pm

Hi Andrew,

Victory at last I found the correct pinout for the 1588BS LED matrix

from top left pin 1 to 8
1:R5 goes to D10
2:R7 goes to D11
3:C2 goes to D12
4:C3 goes to D13
5:R8 goes to A3
6:C5 goes to A2
7:R6 goes to A1
8:R3 goes to A0

from bottom right pin 9 to 16
9: R1 goes to D9
10:C4 goes to D8
11:C6 goes to D7
12:R4 goes to D6
13:C1 goes to D5
14:R2 goes to D4
15:C7 goes to D3
16:C8 goes to D2

*All C's must be connected through a 220 ohm resistor
sketches are working now
mus be an older model of display than the one you're offering now with a different pinout than presented in the sketch info
:lol:
thanks a lot for the support

:oops: see now i had it reversed

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCDotMatrix Arduino library for 8x8 LED dot matrix modul

Post by andrew » Sat Apr 18, 2015 8:21 am

That's great. We did indeed change the modules in the kit but this was quite some time ago so you must have a very old kit. I could still do with looking at the library because it's getting a little out of date and would benefit with a update.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Arduino”