고급 예제

다양한 도구들을 가지고 마음껏 응용해보세요.

64x16 LED matrix를 사용해보자

2014-10-02 11:38:38

개요

개요

LED matrix는 각각의 LED들이 하나의 Pixel의 역할을 해서 다수의 LED가 정렬되어 기판에 붙여져 있는 기기를 말한다.




대체적으로 LEd matrix라 하면 대체적으로 8x8 LED matrix를 많이 사용한다.
8x8 LED matrix의 경우에는 작기 때문에 LED matrix의 역할이 필요한 곳에 간단하게 사용이 가능하고, 작기 때문에 프로그래밍을 하기가 쉽다는 장점이 있다.
하지만 그만큼 표현할 수 있는 모양이 작다는 것은 단점이다.
반대로 말하면 LEDmatrix가 클수록 표현할 수 있는 가짓수는 늘어나지만 그만큼 프로그래밍하기가 어려워진다.




LEDmatrix의 역할은 굳이 말 안해도 생활 주변에서 광고판이나 알림판 등으로 많이 사용하기 때문에 한번 이상씩을 봤을 것이라 생각한다.
그만큼 LEDmatrix는 응용을 하지 않아도 그 자체로도 활용이 가능한 제품이다.



아두이노를 사용하여 큰편에 속하는 64x16 LEDmatrix를 제어해 보자. 
직접 프로그래밍하지는 못하고 예제나 인터넷에 존재하는 다른 소스를 사용하여 제어해볼 것이다.

동영상


필요한 사전지식

부품 목록

NO 부품명 수량 상세설명
1 아두이노 1 오렌지 보드
2 64x16 LED matrix  1 3.75mm 64x16 Dot Matrix LED Display
3 점퍼케이블 10 점퍼케이블
4 아답터 1 DC 5V

부품명 아두이노 64X16 LED matrix 점퍼케이블 아답터
부품 사진

64x16 LED matrix의 제품이 다 같은 기종이 아니기 때문에 현재 가지고 사용중에 있는 제품인
http://www.canton-electronics.com/375mm-64x16-dot-matrix-led-display-for-arduino-uno-r3-mega2560-mcu-sign-project-p-753.html
위 사이트의 제품을 기준으로 작성하였다. 따라서 기능이 같아도 기종이 다를 경우 이 튜토리얼이 해당되지 않을 수 있다.

하드웨어 making



TB275_11
출처 : http://www.canton-electronics.com/

 

소프트웨어 coding


//Author: cantone-electonics
//More information welcome to : http://www.canton-electronics.com 
//Arduino 1.0.4
//Arduino uno R3
//64x16 Matrix LED

#define COL_PIXEL     64
#define ROW_PIXEL     16

int latchPin=8; //LT
int clockPin=12;//SK
int dataPin=11; //R1

int en_74138 = 2;
int la_74138 = 3;
int lb_74138 = 4;
int lc_74138 = 5;
int ld_74138 = 6;
 
unsigned int ROW_xPixel;
unsigned int ROW_num;
unsigned char Col_num_1;
unsigned char Col_num_2;
unsigned char Col_num_3;
unsigned char Col_num_4;
unsigned char Col_num_5;
unsigned char Col_num_6;
unsigned char Col_num_7;
unsigned char Col_num_8;


//Data code: Horizontal modulus ,Bytes reverse order
unsigned char  Bmp1[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 64X16
;I Love You
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0xff, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xc, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x3, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x3, 0xc0, 0x3, 0x3, 0x30, 0xf0, 0x0, 0xc0, 0xc, 
0xf0, 0xc0, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0x30, 0xc, 0x3, 0x30, 0xc, 0x3, 0x0, 0x3, 0xc, 0xc3, 0x0, 0x3, 0x0, 0xc,
0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0x3, 0xc, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30,
0x3, 0xc, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0xf, 0xc, 0x0, 0x3, 0x3, 0xcc, 
0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 0xc, 0x30, 0x3, 0x30, 0xf3, 0x3, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0x3, 
0xc, 0x30, 0xc, 0xc, 0x3, 0x0, 0x0, 0x3, 0x3, 0xcc, 0x0, 0x3, 0x0, 0xc, 0x0, 0xc3, 0x30, 0xc, 0x30, 0x3, 0x3, 0xc, 
0x0, 0x3, 0xc, 0xc3, 0x0, 0x3, 0xc0, 0xff, 0x0, 0xff, 0xc0, 0x3, 0xc0, 0x0, 0xfc, 0x3, 0x0, 0x3, 0xf0, 0x0, 0xff, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 
};



unsigned char  Bmp2[]=
{
/*------------------------------------------------------------------------------
; Width X height (pixels): 16X16
;WELCOME 64 16
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3c, 0x30, 0xf0, 0xfc, 0xff, 0x3c, 0x0, 
0xf0, 0x3f, 0xf0, 0xf, 0x3c, 0x0, 0xcf, 0xff, 0x3f, 0x3c, 0xf0, 0xf0, 0xfc, 0xff, 0x3c, 0x0, 0xfc, 0x3f, 0xfc, 0x3f, 0x3c, 
0x0, 0xcf, 0xff, 0x3f, 0x3c, 0xf0, 0xf0, 0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0x0, 0xcf, 0x3, 0x0, 0x3c, 0xfc,
0xf0, 0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0xfc, 0xc0, 0xcf, 0x3, 0x0, 0x3c, 0xfc, 0xf0, 0x3c, 0x0, 0x3c, 0x0, 0xf, 
0x0, 0xf, 0xf0, 0xfc, 0xf0, 0xcf, 0x3, 0x0, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0xfc, 0xf3, 0xcf,
0xff, 0x3f, 0xf0, 0xfc, 0x3c, 0xfc, 0xff, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0x3f, 0xcf, 0xff, 0x3f, 0xf0, 0xfc, 0x3c, 
0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0x3f, 0xcf, 0x3, 0x0, 0xf0, 0xfc, 0x3c, 0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0,
0xf, 0xf0, 0x3c, 0x3f, 0xcf, 0x3, 0x0, 0xf0, 0xff, 0x3f, 0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0x3f, 0xcf, 0x3,
0x0, 0xf0, 0xff, 0x3f, 0x3c, 0x0, 0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0x3f, 0xcf, 0x3, 0x0, 0xc0, 0xcf, 0xf, 0x3c, 0x0, 
0x3c, 0x0, 0xf, 0x0, 0xf, 0xf0, 0x3c, 0xf, 0xcf, 0x3, 0x0, 0xc0, 0xcf, 0xf, 0xfc, 0xff, 0xfc, 0xff, 0xfc, 0x3f, 0xfc, 0x3f, 
0x3c, 0xc, 0xcf, 0xff, 0x3f, 0x0, 0x3, 0x3, 0xfc, 0xff, 0xfc, 0xff, 0xf0, 0x3f, 0xf0, 0xf, 0x3c, 0xc, 0xcf, 0xff, 0x3f, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};

unsigned char  Bmp3[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 64X16
;diameter_3.75mm
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0xf0, 0xf, 0xc0, 0xff, 0x3f,
0xfc, 0xff, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0xc, 0x30, 0x0, 0x0, 0x30, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x30, 0x0, 0x0, 0xc0, 0x0, 0x0, 0xc, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x3, 0x0, 0xc0, 0x0, 0x0, 0x3,
0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x30, 0xc, 0x0, 0xc0, 0x0, 0xc0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x30, 0x30, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, 0xfc, 0xf, 0x0, 0xf, 0x3c, 0xf0, 0xc0, 0x3, 0x30, 0x30, 0x30, 0xfc, 0xf, 0x0, 
0x30, 0x0, 0x0, 0x30, 0xc0, 0x30, 0xc3, 0xc, 0x33, 0xc, 0x30, 0x30, 0x30, 0x0, 0x30, 0x0, 0x30, 0x0, 0x0, 0xc0, 0xc0, 0xc0,
0xc0, 0xc, 0xc, 0xc, 0x30, 0x30, 0x30, 0x0, 0xc0, 0x0, 0x30, 0x0, 0x0, 0x0, 0xc3, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0xc0, 0x30, 0xc
, 0x0, 0xc0, 0x0, 0x30, 0x0, 0x0, 0x0, 0xc3, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0x0, 0xff, 0x3, 0x0, 0xc0, 0x3c, 0x30, 0x0, 0x0, 0x0,
0xc3, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0x0, 0x30, 0x0, 0x0, 0xc0, 0x3c, 0x30, 0x0, 0x0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0x0, 
0x30, 0x0, 0xc, 0x30, 0x0, 0x30, 0x0, 0x0, 0x30, 0xc0, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0x0, 0xfc, 0x0, 0xf0, 0xf, 0x0, 0x30, 0x0,
0xfc, 0xf, 0xc0, 0xc0, 0xc0, 0xc, 0xc, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 

};

unsigned char  Bmp4[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 64X16
; ARDUINO
------------------------------------------------------------------------------*/
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3c, 0xc0, 0xff, 0x3, 0xff, 0xf, 0xc, 
0x0, 0xc3, 0xff, 0xc, 0x0, 0x3, 0xff, 0x0, 0x0, 0xc3, 0xc0, 0x0, 0xc, 0x3, 0x30, 0xc, 0x0, 0x3, 0xc, 0x3c, 0x0, 0xc3, 0x0,
0x3, 0xc0, 0x0, 0xc3, 0x0, 0x30, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xcc, 0x0, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x0, 0x30, 0x3,
0xc0, 0xc, 0x0, 0x3, 0xc, 0xcc, 0x0, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x0, 0x30, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 0x3,
0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x0, 0xc, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 0x3, 0x33, 0x0, 0xc, 0xf0, 0xff, 0xcf, 0xff,
0x3, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 0x3, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x3, 0x0, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc,
0xc, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0xc, 0x0, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 0xc, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x30,
0x0, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 0xc, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0xc0, 0x0, 0x3, 0xc0, 0xc, 0x0, 0x3, 0xc, 0xc, 
0x30, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x0, 0x3, 0x3, 0x30, 0xc, 0x0, 0x3, 0xc, 0xc, 0x30, 0x33, 0x0, 0xc, 0x30, 0x0, 0xcc, 0x0,
0xc, 0x3, 0xc, 0x30, 0xc0, 0x0, 0xc, 0xc, 0xc0, 0xc3, 0x0, 0x3, 0x30, 0x0, 0xcc, 0x0, 0x30, 0xff, 0x3, 0xc0, 0x3f, 0xc0, 0xff, 0xc,
0x0, 0x3, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 
};

unsigned char  Bmp5[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 16X16
;arduino_martix
------------------------------------------------------------------------------*/
0xc0, 0xc0, 0xf, 0x3f, 0xc, 0xf3, 0x33, 0xc, 0xf, 0xc, 0x33, 0xc, 0xf, 0xfc, 0xc0, 0x3, 0x30, 0xc3, 0x30, 0xc3, 0xc, 0xc3, 0xf0, 
0xcc, 0x30, 0xc, 0xf3, 0xcc, 0x30, 0xc, 0x33, 0xc, 0xc, 0xcc, 0x30, 0xc3, 0xc, 0xc3, 0xf0, 0xcc, 0x30, 0xc, 0xf3, 0xcc, 0x30, 0xc, 
0x3, 0xc, 0xfc, 0xcf, 0xf, 0xc3, 0xc, 0xc3, 0x30, 0xcf, 0x30, 0xc, 0x33, 0xcf, 0x30, 0xfc, 0xc0, 0x3, 0xc, 0xcc, 0x3, 0xc3, 0xc,
0xc3, 0x30, 0xcf, 0x30, 0xc, 0x33, 0xcf, 0x30, 0x3c, 0x0, 0xc, 0xc, 0xcc, 0xc, 0xc3, 0xc, 0xc3, 0x30, 0xcf, 0x30, 0xc, 0x33, 0xcf,
0x30, 0xcc, 0x30, 0xc, 0xc, 0xcc, 0x30, 0x3f, 0xf0, 0xf0, 0x33, 0xc, 0xf, 0xf0, 0x30, 0xc, 0xf, 0xc, 0xc3, 0x3, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xc, 0xc, 0xc, 0xfc, 0xfc, 0xf0, 0x33, 0x30, 0x0, 0x0, 0xf, 0x33, 0x0, 0x0, 0xc3, 0x3, 0x3c, 0xf, 0x33, 0x30, 0xc, 0xc3,
0xc0, 0xc, 0x0, 0xc0, 0x30, 0x33, 0x0, 0xc0, 0x33, 0xc, 0xcc, 0xcc, 0xc0, 0x30, 0xc, 0xc3, 0xc0, 0x3, 0x0, 0xc0, 0x0, 0x33, 0xc,
0xc, 0x33, 0x0, 0xc, 0xcc, 0xff, 0x30, 0xfc, 0xc0, 0x0, 0x3, 0x0, 0xc0, 0xf, 0xff, 0x30, 0x3, 0xf3, 0x3, 0xc, 0xcc, 0xc0, 0x30, 
0x3c, 0xc0, 0xc0, 0xc, 0x0, 0xc0, 0x30, 0x30, 0xc0, 0x0, 0x33, 0xc, 0xc, 0xcc, 0xc0, 0x30, 0xcc, 0xc0, 0xc0, 0xc, 0x0, 0xc0, 0x30,
0x30, 0x30, 0x3, 0x33, 0xc, 0xc, 0xcc, 0xc0, 0x30, 0xc, 0xf3, 0x33, 0x30, 0x0, 0x0, 0xf, 0x30, 0xc, 0xcc, 0xcf, 0x3

};

unsigned char  Bmp6[]=
{
/*------------------------------------------------------------------------------
;  Width X height (pixels): 64X16
;merry_christmas
------------------------------------------------------------------------------*/
 0x0, 0x0, 0x30, 0x30, 0xff, 0xfc, 0xf0, 0xc3, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x00, 0x30, 0x30, 0x3, 0xc, 0x33, 
 0xc, 0x33, 0x0, 0x0, 0x0, 0x0, 0xc0, 0xc, 0x0, 0x0, 0x0, 0xf0, 0x3c, 0x3, 0xc, 0x33, 0xc, 0xc, 0x0, 0x0, 0x0, 0x0, 0x30, 0x30,
 0x0, 0x0, 0x0, 0x30, 0x33, 0xff, 0xfc, 0xf0, 0x3, 0xc, 0x0, 0x0, 0x0, 0x0, 0xfc, 0xff, 0x0, 0x0, 0x0, 0x30, 0x33, 0x3, 0x3c,
 0xf0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0xc0, 0xc, 0x0, 0x0, 0x0, 0x30, 0x33, 0x3, 0xcc, 0x30, 0x3, 0xc, 0x0, 0x0, 0x0, 0x0, 0x30,
 0x30, 0x0, 0x0, 0x0, 0x30, 0x33, 0xff, 0xc, 0x33, 0xc, 0xc, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x0, 0x0, 
 0xc, 0xf0, 0x30, 0xcc, 0xf, 0x3f, 0x3c, 0xfc, 0xc, 0xc, 0xc, 0xf0, 0xc0, 0xf0, 0xff, 0xff, 0x3f, 0xc, 0x33, 0xcc, 0x30, 0xc, 
 0xc3, 0x30, 0xc, 0xc, 0x33, 0xc, 0xc3, 0x0, 0x0, 0x3, 0x0, 0xc, 0x30, 0xcc, 0x30, 0xc, 0x3, 0x30, 0x3c, 0xcf, 0xc0, 0xc, 0xc0,
 0x0, 0x0, 0x3, 0x0, 0xc, 0xf0, 0xcf, 0xf, 0xc, 0x3c, 0x30, 0xcc, 0xcc, 0xff, 0xf0, 0xc0, 0x0, 0x0, 0x3, 0x0, 0xc, 0x30, 0xcc,
 0x3, 0xc, 0xc0, 0x30, 0xcc, 0xcc, 0xc0, 0x0, 0xc3, 0x0, 0x0, 0x3, 0x0, 0xc, 0x33, 0xcc, 0xc, 0xc, 0xc3, 0x30, 0xcc, 0xcc, 0xc0,
 0xc, 0x3, 0x0, 0x0, 0x3, 0x0, 0xf0, 0x30, 0xcc, 0x30, 0x3f, 0x3c, 0x30, 0xcc, 0xcc, 0xc0, 0xf0, 0xc0, 0x0, 0x0, 0x3, 0x0 


};


void shiftOut(unsigned char dataOut)
{
  
    for(int i=0;i<=7;i++)
   {
      PORTB &=~(1<<(clockPin-8));//equate digitalWrite(clockPin,LOW);
       
     if(dataOut & (0x01<<i))  PORTB |=1<<(dataPin-8); //equate digitalWrite(dataPin,HIGH);
     else  PORTB &=~(1<<(dataPin-8));//equate digitalWrite(dataPin,LOW);
     
     PORTB |=1<<(clockPin-8);//equate digitalWrite(clockPin,HIGH);
     
   }
}

//Combine 2 bits/pixel to 1 bits/pixel 
unsigned char Combine_2BitsTo1Bit(unsigned char num,unsigned char *BMP)
{
  
  unsigned char Col_num_tem_1;
  unsigned char Col_num_tem_2;
  unsigned int Col_num_tem = 0;
  unsigned char i=0;
  unsigned char Col_num_1bit = 0x00;
  
  Col_num_tem_1 = *(BMP+num);
  Col_num_tem_2 = *(BMP+num+1);
  
  Col_num_tem = Col_num_tem_1;
  Col_num_tem |= (Col_num_tem_2 << 8);
  
 for(i=0;i<8;i++)
  {   
    if(Col_num_tem&(0x0003<<i*2)) Col_num_1bit |= (0x01<<i);
  }
  return ~Col_num_1bit;
}

//display one picture 
void display_martix(unsigned char *BMP)
{
  //Display count
  unsigned int dis_cnt=256;
  unsigned int i;
  
   for(i=0;i<dis_cnt*16;i++)
   {
     
     digitalWrite(en_74138, HIGH);//Turn off display
  
     //Col scanning
    shiftOut(Col_num_1);
    shiftOut(Col_num_2);
    shiftOut(Col_num_3);
    shiftOut(Col_num_4);
    shiftOut(Col_num_5);
    shiftOut(Col_num_6);
    shiftOut(Col_num_7);
    shiftOut(Col_num_8);
  
    digitalWrite(latchPin, LOW);
    digitalWrite(latchPin, HIGH);
  
    //Row scanning
    // AVR Port Operation 
    PORTD = ((ROW_xPixel << 3 ) & 0X78) | (PORTD & 0X87);//Write PIN 3 4 5 6 la_74138 lb_74138 lc_74138 ld_74138
     
    digitalWrite(en_74138, LOW);//Turn on display
  

     
    if(ROW_xPixel==15) ROW_xPixel=0; else ROW_xPixel++;
  
   /*
   // Single color,1 bits/pixel
   Col_num_1=~BMP[(COL_PIXEL/8)*ROW_xPixel];
   Col_num_2=~BMP[(COL_PIXEL/8)*ROW_xPixel+1];
   Col_num_3=~BMP[(COL_PIXEL/8)*ROW_xPixel+2];
   Col_num_4=~BMP[(COL_PIXEL/8)*ROW_xPixel+3];
   Col_num_5=~BMP[(COL_PIXEL/8)*ROW_xPixel+4];
   Col_num_6=~BMP[(COL_PIXEL/8)*ROW_xPixel+5];
   Col_num_7=~BMP[(COL_PIXEL/8)*ROW_xPixel+6];
   Col_num_8=~BMP[(COL_PIXEL/8)*ROW_xPixel+7];
 */
   
   //Single color,2 bits/pixel 
   Col_num_1 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2,BMP);
   Col_num_2 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+2,BMP);
   Col_num_3 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+4,BMP);
   Col_num_4 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+6,BMP);
   Col_num_5 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+8,BMP);
   Col_num_6 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+10,BMP);
   Col_num_7 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+12,BMP);
   Col_num_8 = Combine_2BitsTo1Bit((COL_PIXEL/8)*ROW_xPixel*2+14,BMP);
  
  // delayMicroseconds(1000); 
   
  }
  
}

void setup()
{
  pinMode(latchPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(dataPin,OUTPUT);
  
  pinMode(en_74138,OUTPUT);
  pinMode(la_74138,OUTPUT);
  pinMode(lb_74138,OUTPUT);
  pinMode(lc_74138,OUTPUT);
  pinMode(ld_74138,OUTPUT);
  
  digitalWrite(en_74138, LOW);
  
  // AVR Port Settings
  DDRD |= 0x78; //Set PIN 3 4 5 6 output  
 
}


void loop()
{
 display_martix(Bmp1);

 display_martix(Bmp2);

 display_martix(Bmp3);

 display_martix(Bmp4);
 
 display_martix(Bmp5);
 
 display_martix(Bmp6);
}

위의 예제는 64x16LEDmatrix를 판매하는 사이트에서 제공하는 소스로 몇가지 예제문구를 표현한다. 

판매처에서 제공하는 예제이기 때문에 보기에는 이쁘지만 문구를 알파벳순으로 정리하지 않고 하나의 비트맵으로 정리하여 표현했기 때문에 따로 응용은 불가능하다.


// Author: Phil Kaziewicz 19th July 2014
// 64x32 LED display matrix test code
// based upon original code from canton-electonics
// Arduino 1.0.5 UNO R3
#include <pgmspace.h>

// Connections to board
const byte latchPin=8;
const byte clockPin=12;
const byte data_R1=10;
const byte data_R2=11;
const byte en_74138=2;
const byte la_74138=3;
const byte lb_74138=4;
const byte lc_74138=5;
const byte ld_74138=6;
byte ScanRow = 0;
unsigned long counter;

const char message[] = "   ";
// (c) Winston Churchill!

byte buffer[256] = { // Display buffer (which is scanned by the interrupt timer) of 8x32 bytes
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
// ---------------------------------------------------------------------------------------------------
// FONTS sourced from various locations on the internet
// full ASCII character set (8x16) (1520 bytes)
const uint8_t font8x16_basic[] PROGMEM = {
        /*   (32) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	/* ! (33) */ 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
	/* " (34) */ 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* # (35) */ 0x00, 0x00, 0x00, 0x00, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, 0x00, 0x00,
	/* $ (36) */ 0x00, 0x18, 0x18, 0x7C, 0xC6, 0xC2, 0xC0, 0x7C, 0x06, 0x06, 0x86, 0xC6, 0x7C, 0x18, 0x18, 0x00,	
        /* % (37) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xC6, 0x0C, 0x18, 0x30, 0x60, 0xC6, 0x86, 0x00, 0x00, 0x00,
	/* & (38) */ 0x00, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00,
	/* ' (39) */ 0x00, 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* ( (40) */ 0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00,
	/* ) (41) */ 0x00, 0x00, 0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00,
	/* * (42) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* + (43) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* , (44) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00,
	/* - (45) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* . (46) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
	/* / (47) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00,
	/* 0 (48) */ 0x00, 0x00, 0x00, 0x3C, 0x66, 0xC3, 0xC3, 0xDB, 0xDB, 0xC3, 0xC3, 0x66, 0x3C, 0x00, 0x00, 0x00,
	/* 1 (49) */ 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00,
	/* 2 (50) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00,
	/* 3 (51) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* 4 (52) */ 0x00, 0x00, 0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00,
	/* 5 (53) */ 0x00, 0x00, 0x00, 0xFE, 0xC0, 0xC0, 0xC0, 0xFC, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* 6 (54) */ 0x00, 0x00, 0x00, 0x38, 0x60, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* 7 (55) */ 0x00, 0x00, 0x00, 0xFE, 0xC6, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00,
	/* 8 (56) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* 9 (57) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x0C, 0x78, 0x00, 0x00, 0x00,
	/* : (58) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
	/* ; (59) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
	/* < (60) */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00,
	/* = (61) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* > (62) */ 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00,
	/* ? (63) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x0C, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
	/* @ (64) */ 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xDE, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00, 0x00, 0x00,
	/* A (65) */ 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00,
	/* B (66) */ 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00,
	/* C (67) */ 0x00, 0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0x66, 0x3C, 0x00, 0x00, 0x00,
	/* D (68) */ 0x00, 0x00, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00,
	/* E (69) */ 0x00, 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00,
	/* F (70) */ 0x00, 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00,
	/* G (71) */ 0x00, 0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xDE, 0xC6, 0xC6, 0x66, 0x3A, 0x00, 0x00, 0x00,
	/* H (72) */ 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00,
	/* I (73) */ 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00,
	/* J (74) */ 0x00, 0x00, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00,
	/* K (75) */ 0x00, 0x00, 0x00, 0xE6, 0x66, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00,
	/* L (76) */ 0x00, 0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00,
	/* M (77) */ 0x00, 0x00, 0x00, 0xC3, 0xE7, 0xFF, 0xFF, 0xDB, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0x00, 0x00, 0x00,
	/* N (78) */ 0x00, 0x00, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00,
	/* O (79) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* P (80) */ 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00,
	/* Q (81) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xDE, 0x7C, 0x0C, 0x0E, 0x00,
	/* R (82) */ 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00,
	/* S (83) */ 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x60, 0x38, 0x0C, 0x06, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* T (84) */ 0x00, 0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00,
	/* U (85) */ 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* V (86) */ 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00,
	/* W (87) */ 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xDB, 0xDB, 0xFF, 0x66, 0x66, 0x00, 0x00, 0x00,
	/* X (88) */ 0x00, 0x00, 0x00, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x66, 0xC3, 0xC3, 0x00, 0x00, 0x00,
	/* Y (89) */ 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00,
	/* Z (90) */ 0x00, 0x00, 0x00, 0xFF, 0xC3, 0x86, 0x0C, 0x18, 0x30, 0x60, 0xC1, 0xC3, 0xFF, 0x00, 0x00, 0x00,
	/* [ (91) */ 0x00, 0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00,
	/* \ (92) */ 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00,
	/* ] (93) */ 0x00, 0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00,
	/* ^ (94) */ 0x00, 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* _ (95) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
	/* ` (96) */ 0x00, 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	/* a (97) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00,
	/* b (98) */ 0x00, 0x00, 0x00, 0xE0, 0x60, 0x60, 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00,
	/* c (99) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* d (100) */ 0x00, 0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x3C, 0x6C, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00,
	/* e (101) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* f (102) */ 0x00, 0x00, 0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00,
	/* g (103) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xCC, 0x78,
	/* h (104) */ 0x00, 0x00, 0x00, 0xE0, 0x60, 0x60, 0x6C, 0x76, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00,
	/* i (105) */ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00,
	/* j (106) */ 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C,
	/* k (107) */ 0x00, 0x00, 0x00, 0xE0, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00,
	/* l (108) */ 0x00, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00,
	/* m (109) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xFF, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00,
	/* n (110) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00,
	/* o (111) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* p (112) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0,
	/* q (113) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0x1E,
	/* r (114) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00,
	/* s (115) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x60, 0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00,
	/* t (116) */ 0x00, 0x00, 0x00, 0x10, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1C, 0x00, 0x00, 0x00,
	/* u (117) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00,
	/* v (118) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00,
	/* w (119) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xDB, 0xDB, 0xFF, 0x66, 0x00, 0x00, 0x00,
	/* x (120) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0xC3, 0x00, 0x00, 0x00,
	/* y (121) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8,
	/* z (122) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xCC, 0x18, 0x30, 0x60, 0xC6, 0xFE, 0x00, 0x00, 0x00,
	/* { (123) */ 0x00, 0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00,
	/* | (124) */ 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
	/* } (125) */ 0x00, 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00,
	/* ~ (126) */ 0x00, 0x00, 0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        /* BLK(127)*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
// full ASCII character set (8x8) (760 bytes)
const uint8_t font8x8_basic[] PROGMEM = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0020 (space)
     0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00,   // U+0021 (!)
     0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0022 (")
     0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00,   // U+0023 (#)
     0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00,   // U+0024 ($)
     0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00,   // U+0025 (%)
     0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00,   // U+0026 (&)
     0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0027 (')
     0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00,   // U+0028 (()
     0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00,   // U+0029 ())
     0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00,   // U+002A (*)
     0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00,   // U+002B (+)
     0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06,   // U+002C (,)
     0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00,   // U+002D (-)
     0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00,   // U+002E (.)
     0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00,   // U+002F (/)
     0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00,   // U+0030 (0)
     0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00,   // U+0031 (1)
     0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00,   // U+0032 (2)
     0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00,   // U+0033 (3)
     0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00,   // U+0034 (4)
     0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00,   // U+0035 (5)
     0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00,   // U+0036 (6)
     0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00,   // U+0037 (7)
     0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00,   // U+0038 (8)
     0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00,   // U+0039 (9)
     0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00,   // U+003A (:)
     0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06,   // U+003B (//)
     0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00,   // U+003C (<)
     0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00,   // U+003D (=)
     0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00,   // U+003E (>)
     0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00,   // U+003F (?)
     0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00,   // U+0040 (@)
     0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00,   // U+0041 (A)
     0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00,   // U+0042 (B)
     0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00,   // U+0043 (C)
     0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00,   // U+0044 (D)
     0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00,   // U+0045 (E)
     0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00,   // U+0046 (F)
     0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00,   // U+0047 (G)
     0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00,   // U+0048 (H)
     0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00,   // U+0049 (I)
     0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00,   // U+004A (J)
     0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00,   // U+004B (K)
     0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00,   // U+004C (L)
     0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00,   // U+004D (M)
     0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00,   // U+004E (N)
     0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00,   // U+004F (O)
     0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00,   // U+0050 (P)
     0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00,   // U+0051 (Q)
     0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00,   // U+0052 (R)
     0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00,   // U+0053 (S)
     0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00,   // U+0054 (T)
     0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00,   // U+0055 (U)
     0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00,   // U+0056 (V)
     0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00,   // U+0057 (W)
     0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00,   // U+0058 (X)
     0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00,   // U+0059 (Y)
     0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00,   // U+005A (Z)
     0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00,   // U+005B ([)
     0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00,   // U+005C (\)
     0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00,   // U+005D (])
     0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00,   // U+005E (^)
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,   // U+005F (_)
     0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+0060 (`)
     0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00,   // U+0061 (a)
     0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00,   // U+0062 (b)
     0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00,   // U+0063 (c)
     0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00,   // U+0064 (d)
     0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00,   // U+0065 (e)
     0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00,   // U+0066 (f)
     0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F,   // U+0067 (g)
     0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00,   // U+0068 (h)
     0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00,   // U+0069 (i)
     0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E,   // U+006A (j)
     0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00,   // U+006B (k)
     0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00,   // U+006C (l)
     0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00,   // U+006D (m)
     0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00,   // U+006E (n)
     0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00,   // U+006F (o)
     0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F,   // U+0070 (p)
     0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78,   // U+0071 (q)
     0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00,   // U+0072 (r)
     0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00,   // U+0073 (s)
     0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00,   // U+0074 (t)
     0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00,   // U+0075 (u)
     0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00,   // U+0076 (v)
     0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00,   // U+0077 (w)
     0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00,   // U+0078 (x)
     0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F,   // U+0079 (y)
     0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00,   // U+007A (z)
     0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00,   // U+007B ({)
     0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,   // U+007C (|)
     0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00,   // U+007D (})
     0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // U+007E (~)
     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,   // U+007F (block)
};

// Routine to print a single character in one of 8 columns
// Inputs:
// x is one of (0,16,24,32,40,48,56), 
// y (0 to 16 or 24 depending upon font size),
// n is either (0 to 9) or an ascii value, 
// font=0 for big font, 2 for small font, 
// inverse is true for an inverted character
void drawChar(uint16_t x, uint16_t y, byte n, byte font, boolean inverse) { 
    byte charbytes[16], fontrows, xover8 = x>>3; 
    int index;
    if (0 != (x % 8)) return;    // x not a multiple of 8
    if ((n>9) && (n<32)) return; // invalid character
    if (font==2) fontrows=16; else fontrows=8;
    if ((n>=0) && (n<=9)) index=(n+16)*fontrows; else index=(n-32)*fontrows; // go to the right code for this character

// addressing start at buffer and add y (rows) * (WIDTH is 64 so WIDTH/8) is 8 plus (x / 8) is 0 to 7
    byte *pDst = buffer + (y << 3) + xover8;
    for (byte i=0;i<fontrows;i++) {  // fill up the charbytes array with the right bits
      if (font==0) charbytes[i] = pgm_read_byte(&(font8x8_basic[index+i]));
//      if (font==1) charbytes[i] = pgm_read_byte(&(font8x8_extended[index+i]));
      if (font==2) charbytes[i] = pgm_read_byte(&(font8x16_basic[index+i]));
      // reverse bit order for fonts 0 and 1
      if (font != 2) {
        charbytes[i] = (charbytes[i] & 0xF0) >> 4 | (charbytes[i] & 0x0F) << 4;
        charbytes[i] = (charbytes[i] & 0xCC) >> 2 | (charbytes[i] & 0x33) << 2;
        charbytes[i] = (charbytes[i] & 0xAA) >> 1 | (charbytes[i] & 0x55) << 1;
      };
      if (inverse) charbytes[i] = ~charbytes[i];
      };
    const byte *pSrc = charbytes; // point at the first set of 8 pixels    
    for (byte i=0; i<fontrows; i++) {
        *pDst = *pSrc;     // populate the destination byte
        pDst += 8;         // go to next row on buffer
        pSrc++;            // go to next set of 8 pixels in character
    }
};

void moveLeft(byte pixels, byte rowstart, byte rowstop) { // routine to move certain rows on the screen "pixels" pixels to the left
byte row, column; 
short unsigned int address;
  for (column=0;column<8;column++) { 
    for (row=rowstart;row<rowstop;row++) {
      address = (row<<3) + column; /// right here!
      if (column==7) 
         buffer[address] = buffer[address]<<pixels; // shuffle pixels left on last column and fill with a blank
        else {                // shuffle pixels left and add leftmost pixels from next column
         byte incomingchar = buffer[address+1];
         buffer[address] = buffer[address]<<pixels;
         for (byte x=0;x<pixels;x++) { buffer[address] += ((incomingchar & (128>>x)) >> (7-x))<<(pixels-x-1); };
         }
     }
  }
};

// set a single pixel on or off
void setPixel(byte x, byte y, byte colour) { bitWrite(buffer[(y<<3)+(x>>3)],7-(x&7),colour); };

void drawRect(byte x1, byte y1, byte x2, byte y2, byte colour) {
  for (byte x=x1;x<=x2;x++) { setPixel(x,y1,colour); setPixel(x,y2,colour); };
  for (byte y=y1;y<=y2;y++) { setPixel(x1,y,colour); setPixel(x2,y,colour); };
};

void shiftOut(byte row) { // fast routine to shove out 8 columns into two rows via board's shift registers
  for(byte column=0;column<8;column++) {
    byte index = column + (row<<3);  
    for(byte i=0;i<8;i++) {    
      PORTB &=~(3<<(data_R1-8));                                 // data_R2 is LOW; data_R1 is LOW;
      PORTB &=~(1<<(clockPin-8));                                // digitalWrite(clockPin,LOW);
      PORTB |= !((buffer[index]>>(7-i)) & 0x01) << (data_R1-8);  // top set of rows
      PORTB |= !((buffer[index+128]>>(7-i)) & 0x01) << (data_R2-8); // bottom set of rows
      PORTB |= 1<<(clockPin-8);                                  // digitalWrite(clockPin,HIGH);
    };
  };
};

// Scan a pair of rows on to the display from "buffer" via the interrupt
ISR(TIMER2_COMPA_vect){  
     cli();
     digitalWrite(en_74138, HIGH);     // Turn off display
     shiftOut(ScanRow);                // Shift out 8 columns
     digitalWrite(latchPin, LOW);
     digitalWrite(latchPin, HIGH);
     PORTD = (ScanRow << 3) | (PORTD & 0X87); // Highlight row: pins 3 4 5 6 (la_74138 lb_74138 lc_74138 ld_74138)
     digitalWrite(en_74138, LOW);     // Turn on display
     ScanRow++;                       // Do the next pair of rows next time this routine is called
     if (ScanRow==16) ScanRow=0;
     sei();
};

void setup() {

// Set up Timer2 as the scanning interrupt timer
  cli(); // clear interrupts
  TCCR2A = 0; TCCR2B = 0; TCNT2  = 0;
  TCCR2B |= (1 << CS12) | (1 << CS10);     // Set 1024 prescaler
               // 160Hz scan rate = 10 frames/second (16 pairs of rows)
  OCR2A = 97;  // 97 = (16,000,000 / (1024*160)) - 1
  TCCR2A |= (1 << WGM21); TIMSK2 |= (1 << OCIE2A);
  
  pinMode(latchPin,OUTPUT);  pinMode(clockPin,OUTPUT);
  pinMode(data_R1,OUTPUT);   pinMode(data_R2,OUTPUT);
    
  pinMode(en_74138,OUTPUT);
  pinMode(la_74138,OUTPUT);  pinMode(lb_74138,OUTPUT);
  pinMode(lc_74138,OUTPUT);  pinMode(ld_74138,OUTPUT);
  
  digitalWrite(en_74138, LOW);
  digitalWrite(data_R1, HIGH); digitalWrite(data_R2, HIGH);
  counter = millis();
  sei(); //allow interrupts
};

// Note that there's no need to do anything with the screen in the main loop.
// Whatever's in "buffer" is constantly scanned out.
void loop() {  
unsigned long clock;
static int count=0;
byte seconds, colour;

  clock = 100000000-((millis()-counter)/10);   
// display clock
  drawChar(0,0,(clock/10000000)%10,2,false);
  drawChar(8,0,(clock/1000000)%10,2,false);
  drawChar(16,0,(clock/100000)%10,2,false);
  drawChar(24,2,',',2,false);
  drawChar(32,0,(clock/10000)%10,2,false);
  drawChar(40,0,(clock/1000)%10,2,false);
  drawChar(48,0,(clock/100)%10,2,false);
  drawChar(56,6,(clock/10)%10,0,false);

  seconds = (clock/20)%10;
  colour = (clock/200)&1;

// draw a rectangle  
  drawRect(seconds*5,18,seconds*5+4,23,colour);
  drawRect(seconds*5+1,19,seconds*5+3,22,!colour);

// draw a blob  
  setPixel(56,20,colour); setPixel(57,20,colour); setPixel(58,20,colour); 
  setPixel(57,19,colour); setPixel(57,21,colour);
    
// display next character of message
    drawChar(56,24,message[count%(sizeof(message)-1)],0,false);
    count = (count + 1);
    // move the text 7 pixels (not 8 because it looks better) to the left
    for (byte i=0; i<7; i++) {
       delay(15);
       moveLeft(1,24,32);
    };
};

위의 소스는 판매처에서 제공하는 기본소스를 바탕으로 개인이 만든 소스이다. 
장점이라하면 알파벳으로 정리되어 있기 때문에 원하는 영어 문구를 자유자재로 표현이 가능하다.

원래는 64x32 LED matrix를 위해 작성된 코드이지만 64x16 LED matrix에서도 별 문제 없이 실행이 가능하다.
처음에 실행한다면 절반을 기준으로 아래쪽에만 글씨가 표현되고, 위쪽에는 사각형이 보일 것이다.
코드를 수정한다면 사각형을 지우고 글씨를 크게 확대 가능하다

const char message[] = "   ";
위 코드는 원하는 메시지를 넣을 수 있는 배열이다.
알파벳별로 이미지배열이 작성되어 있기 때문에 다음 " "사이에 원하는 영어 문구를 넣으면 LEDmatrix를 통해 표현이 가능하다.

// draw a rectangle  
  drawRect(seconds*5,18,seconds*5+4,23,colour);
  drawRect(seconds*5+1,19,seconds*5+3,22,!colour);

// draw a blob  
  setPixel(56,20,colour); setPixel(57,20,colour); setPixel(58,20,colour); 
  setPixel(57,19,colour); setPixel(57,21,colour);
위 부분은 상단부에 사각형을 그리는 부분이다. 삭제할 경우 사각형은 나타나지 않는다. 

// display next character of message
    drawChar(56,24,message[count%(sizeof(message)-1)],0,false);
    count = (count + 1);
    // move the text 7 pixels (not 8 because it looks better) to the left
    for (byte i=0; i<7; i++) {
       delay(15);
       moveLeft(1,24,32);
    };
위 부분이 메시지를 출력하는 부분이다. 
변수에 대해 설명하게 되면
drawChar(56,24,message[count%(sizeof(message)-1)],0,false);
56은 글씨가 시작되는 가로 위치를 나타낸다. 56일 경우에는 가로 56번째 LED부터 글씨가 나타나게 된다. 즉 오른쪽 끝부분에서 글씨가 나오게 된다.
24는 글씨의 세로 밑 부분을 나타낸다. 24일 경우 글씨의 밑 부분의 위치가 세로 24번째 LED가 된다. 
message는 메시지 글자의 주어진 번호를 나타낸다. 
0은 글씨의 크기를 나타낸다. 0일 경우에는 글씨의 크기가 8이고 2일 경우에는 글씨의 크기가 16이 된다.
false는 글씨의 반전을 나타낸다. false일 경우 글씨부분만 LED가 켜지지만 true일 경우 글씨부분을 제외만 바탕에 LED가 켜진다.
for (byte i=0; i<7; i++) {
       delay(15);
       moveLeft(1,24,32);
    };
for문의 숫자 7은 글자사이의 간격을 나타낸다. 커질수록 간격은 벌어진다.
delay()는 글자의 이동 속도를 나타낸다. 커질수록 글자가 오른쪽에서 왼쪽으로 느리게 이동하게 된다.
moveLeft(1,24,32)는 글자를 이동시키는 함수로 인자값 1은 글자를 몇칸씩 이동시킬지 결정하는 값이다. 1일 경우 글자를 한칸한칸 오른쪽에서 왼쪽으로 이동시키게 된다. 24와 32는 어느 위치 사이의 글자를 이동시킬지 결정하는 값이다. 24와 32가 적혀있다면 세로로 24번째 LED부터 32번째 LED 사이에 있는 글자를 모두 이동시키게 된다. 
참고로 이 소스는 64x32 LED matrix를 기준으로 작성하였기 때문에 LED의 맨 밑부분의 LED가 16이 아닌 32로 표현된다. 
따라서 현재 LEDmatrix상의 범위를 모두 이동시키고 싶다면 16, 32를 적어 주어야한다.

기술문서

  • 부품목록
  • 회로도
  • 브레드보드 레이아웃
  • 스케치

kocoafabeditor

항상 진취적이고, 새로운 것을 추구하는 코코아팹 에디터입니다!

아두이노 LEDmatrix

만봉기 2018-05-05 14:32:13

안녕하세요 혹시 죄송한데 아두이노보드랑 도트매트릭스랑 연결하려고하는데 회로도좀 알수있을까요?

이학선 2018-11-12 18:07:57

아두이노보드와 어떻게 연결되는지 알고 싶습니다.