LED Matrix Display

Video.

Berikut adalah projek LED matrix display berbasis mikrokontroler atmega32 dan compiler CVAVR. Disini digunakan LED dot matrix 8×8, ukuran kolom dalam satu huruf terdiri dari 6 kolom. 74HC595 digunakan untuk membantu kerja kontroler. Berikut rangkaiannya.

led_display

IC 74HC595 sendiri adalah shift register dengan input serial. Berikut ulasan dan timing diagram untuk IC tersebut.

LED_display_3

LED_display_2

Berikut adalah hasil simulasi.

led_display2

Ada yang harus diperhatikan dalam mendesain led matrix display ini, yaitu nilai minimum trigger time yang ada pada led matrix itu sendiri. Apabila nilai tersebut tidak terpenuhi oleh kontroler, maka tulisan tidak akan muncul atau hasilnya jelek. Dalam simulasi yang saya lakukan, minimum trigger time-nya saya misalkan 100us (saya tidak tahu berapa nilainya pada komponen nyata).

Berikut adalah kodingan utamanya.

/*****************************************************
Chip type           : ATmega32
Program type        : Application
Clock frequency     : 16.000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 512
*****************************************************/

#include <mega32.h> 
#include "LED_display.h"

void main (void)
{   
int     i,
        panjang_geser;   
unsigned int    tanggal = 12,
                bulan = 5,
                tahun = 2013;
        LED_init();        
while(1)        
{                             
        LED_clear();
        sprintf(data_kata,"Tanggal:%d/%d/%d",tanggal,bulan,tahun);
        panjang_geser = (strlen(data_kata)*6)+1; 
        LED_update_buffer();
        for(i=18;i>-panjang_geser;i--)
        {               
                LED_gotox = i;     
                LED_refreshrate(5,1); 
        }     
        for(i=96;i>-panjang_geser;i--)
        {               
                LED_gotox = i;     
                LED_refreshrate(5,0); 
        }  
}       
}

Berikut kodingan LED_display.c atau LED_display.h

/*======24 April 2013=====
 © WANGREADY.WORDPRESS.COM
      LED_display.c
email:wangready@yahoo.com 
=========================*/
#include <math.h> 
#include <delay.h>      
#include <stdio.h> 
#include <string.h>  

flash unsigned char font[] = {
0x00,0x00,0x00,0x00,0x00,0x00,//0/ -->  
0x00,0x00,0x00,0x00,0x00,0x00, //1/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //2/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //3/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //4/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //5/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //6/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //7/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //8/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //9/ -->     
0x00,0x00,0x00,0x00,0x00,0x00, //10/ --> 

0x00,0x00,0x00,0x00,0x00,0x00, //11/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //12/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //13/ --> 

0x00,0x00,0x00,0x00,0x00,0x00, //14/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //15/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //16/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //17/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //18/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //19/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //20/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //21/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //22/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //23/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //24/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //25/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //26/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //27/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //28/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //29/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //30/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //31/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //32/ -->  
0x00,0x00,0x4F,0x00,0x00,0x00, //33/ --> !
0x00,0x07,0x00,0x07,0x00,0x00, //34/ --> "
0x00,0x14,0x7F,0x14,0x7F,0x14, //35/ --> #
0x00,0x24,0x2A,0x7F,0x2A,0x12, //36/ --> $
0x00,0x23,0x13,0x08,0x64,0x62, //37/ --> %
0x00,0x36,0x49,0x55,0x22,0x40, //38/ --> &
0x00,0x00,0x05,0x03,0x00,0x00, //39/ --> '
0x00,0x1C,0x22,0x41,0x00,0x00, //40/ --> (
0x00,0x41,0x22,0x1C,0x00,0x00, //41/ --> )
0x00,0x14,0x08,0x3E,0x08,0x14, //42/ --> *
0x00,0x08,0x08,0x3E,0x08,0x08, //43/ --> +
0x00,0x00,0xA0,0x60,0x00,0x00, //44/ --> ,
0x00,0x08,0x08,0x08,0x08,0x08, //45/ --> -
0x00,0x60,0x60,0x00,0x00,0x00, //46/ --> .
0x00,0x20,0x10,0x08,0x04,0x02, //47/ --> /
0x00,0x3E,0x51,0x49,0x45,0x3E, //48/ --> 0
0x00,0x00,0x42,0x7F,0x40,0x00, //49/ --> 1
0x00,0x42,0x61,0x51,0x49,0x46, //50/ --> 2
0x00,0x21,0x41,0x45,0x4B,0x31, //51/ --> 3
0x00,0x18,0x14,0x12,0x7F,0x10, //52/ --> 4
0x00,0x27,0x45,0x45,0x45,0x39, //53/ --> 5
0x00,0x3C,0x4A,0x49,0x49,0x30, //54/ --> 6
0x00,0x01,0x71,0x09,0x05,0x03, //55/ --> 7
0x00,0x36,0x49,0x49,0x49,0x36, //56/ --> 8
0x00,0x06,0x49,0x49,0x29,0x1E, //57/ --> 9
0x00,0x00,0x36,0x36,0x00,0x00, //58/ --> :
0x00,0x00,0x56,0x36,0x00,0x00, //59/ --> ;
0x00,0x08,0x14,0x22,0x41,0x00, //60/ --> <
0x00,0x24,0x24,0x24,0x24,0x24, //61/ --> =
0x00,0x00,0x41,0x22,0x14,0x08, //62/ --> >
0x00,0x02,0x01,0x51,0x09,0x06, //63/ --> ?
0x00,0x32,0x49,0x79,0x41,0x3E, //64/ --> @
0x00,0x7E,0x11,0x11,0x11,0x7E, //65/ --> A
0x00,0x7F,0x49,0x49,0x49,0x36, //66/ --> B
0x00,0x3E,0x41,0x41,0x41,0x22, //67/ --> C
0x00,0x7F,0x41,0x41,0x22,0x1C, //68/ --> D
0x00,0x7F,0x49,0x49,0x49,0x41, //69/ --> E
0x00,0x7F,0x09,0x09,0x09,0x01, //70/ --> F
0x00,0x3E,0x41,0x49,0x49,0x3A, //71/ --> G
0x00,0x7F,0x08,0x08,0x08,0x7F, //72/ --> H
0x00,0x00,0x41,0x7F,0x41,0x00, //73/ --> I
0x00,0x20,0x40,0x41,0x3F,0x01, //74/ --> J
0x00,0x7F,0x08,0x14,0x22,0x41, //75/ --> K
0x00,0x7F,0x40,0x40,0x40,0x40, //76/ --> L
0x00,0x7F,0x02,0x0C,0x02,0x7F, //77/ --> M
0x00,0x7F,0x04,0x08,0x10,0x7F, //78/ --> N
0x00,0x3E,0x41,0x41,0x41,0x3E, //79/ --> O
0x00,0x7F,0x09,0x09,0x09,0x06, //80/ --> P
0x00,0x3E,0x41,0x51,0x21,0x5E, //81/ --> Q
0x00,0x7F,0x09,0x19,0x29,0x46, //82/ --> R
0x00,0x46,0x49,0x49,0x49,0x31, //83/ --> S
0x00,0x01,0x01,0x7F,0x01,0x01, //84/ --> T
0x00,0x3F,0x40,0x40,0x40,0x3F, //85/ --> U
0x00,0x1F,0x20,0x40,0x20,0x1F, //86/ --> V
0x00,0x3F,0x40,0x38,0x40,0x3F, //87/ --> W
0x00,0x63,0x14,0x08,0x14,0x63, //88/ --> X
0x00,0x07,0x08,0x70,0x08,0x07, //89/ --> Y
0x00,0x61,0x51,0x49,0x45,0x43, //90/ --> Z
0x00,0x7F,0x41,0x41,0x00,0x00, //91/ --> [
//0x00,0x15,0x16,0x7C,0x16,0x15, //92/ --> ¥ 
0x00,0x02,0x04,0x08,0x10,0x20, //92/ --> \
// 00000000 0x00
// 00000010 0x02
// 00000100 0x04
// 00001000 0x08
// 00010000 0x10
// 00100000 0x20
0x00,0x41,0x41,0x7F,0x00,0x00, //93/ --> ]
0x00,0x04,0x02,0x01,0x02,0x04, //94/ --> ^
0x00,0x40,0x40,0x40,0x40,0x40, //95/ --> _
0x00,0x01,0x02,0x04,0x00,0x00, //96/ --> `
0x00,0x20,0x54,0x54,0x54,0x78, //97/ --> a
0x00,0x7F,0x44,0x44,0x44,0x38, //98/ --> b
0x00,0x38,0x44,0x44,0x44,0x00, //99/ --> c
0x00,0x38,0x44,0x44,0x48,0x7F, //100/ --> d
0x00,0x38,0x54,0x54,0x54,0x18, //101/ --> e
0x00,0x10,0x7E,0x11,0x01,0x02, //102/ --> f
//0x00,0x18,0xA4,0xA4,0xA4,0x7C, //103/ --> g 
  0x00,0x18,0x54,0x54,0x54,0x7C, //103/ --> g baru
// 00000000 0x00
// 00011000 0x18
// 01010100 0x54
// 01010100 0x54
// 01010100 0x54
// 01111100 0x7C
0x00,0x7F,0x08,0x04,0x04,0x78, //104/ --> h
0x00,0x00,0x44,0x7D,0x40,0x00, //105/ --> i
0x00,0x20,0x40,0x40,0x3D,0x00, //106/ --> j
0x00,0x7F,0x10,0x28,0x44,0x00, //107/ --> k
0x00,0x00,0x41,0x7F,0x40,0x00, //108/ --> l
0x00,0x7C,0x04,0x18,0x04,0x78, //109/ --> m
0x00,0x7C,0x08,0x04,0x04,0x78, //110/ --> n
0x00,0x38,0x44,0x44,0x44,0x38, //111/ --> o
0x00,0x7C,0x14,0x14,0x14,0x08, //112/ --> p
0x00,0x08,0x14,0x14,0x18,0x7C, //113/ --> q
0x00,0x7C,0x08,0x04,0x04,0x08, //114/ --> r
0x00,0x48,0x54,0x54,0x54,0x20, //115/ --> s
0x00,0x04,0x3F,0x44,0x40,0x20, //116/ --> t
0x00,0x3C,0x40,0x40,0x20,0x7C, //117/ --> u
0x00,0x1C,0x20,0x40,0x20,0x1C, //118/ --> v
0x00,0x3C,0x40,0x30,0x40,0x3C, //119/ --> w
0x00,0x44,0x28,0x10,0x28,0x44, //120/ --> x
//0x00,0x0C,0x90,0x90,0x90,0x7C, //121/ --> y
  0x00,0x0C,0x50,0x50,0x50,0x3C, //121/ --> y baru
// 00000000 0x00
// 00001100 0x0C
// 01010000 0x50
// 01010000 0x50
// 01010000 0x50
// 00111100 0x3C
0x00,0x44,0x64,0x54,0x4C,0x44, //122/ --> z
0x00,0x08,0x36,0x41,0x00,0x00, //123/ --> {
0x00,0x00,0x00,0x7F,0x00,0x00, //124/ --> |
0x00,0x41,0x36,0x08,0x00,0x00, //125/ --> }
//0x00,0x08,0x08,0x2A,0x1C,0x08, //126/ --> ~
0x00,0x06,0x01,0x06,0x04,0x03, //126/ --> ~
// 00000000 0x00
// 00000110 0x06
// 00000001 0x01
// 00000110 0x06
// 00000100 0x04
// 00000011 0x03
0x00,0x08,0x1C,0x2A,0x08,0x08, //127/ --> 
0x00,0x3C,0x42,0x41,0x42,0x3C, //128/ --> €
0x00,0x00,0x00,0x00,0x00,0x00, //129/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //130/ --> ‚
0x00,0x00,0x00,0x00,0x00,0x00, //131/ --> ƒ
0x00,0x00,0x00,0x00,0x00,0x00, //132/ --> „
0x00,0x00,0x00,0x00,0x00,0x00, //133/ --> …
0x00,0x00,0x00,0x00,0x00,0x00, //134/ --> †
0x00,0x00,0x00,0x00,0x00,0x00, //135/ --> ‡
0x00,0x00,0x00,0x00,0x00,0x00, //136/ --> ˆ
0x00,0x00,0x00,0x00,0x00,0x00, //137/ --> ‰
0x00,0x00,0x00,0x00,0x00,0x00, //138/ --> Š
0x00,0x00,0x00,0x00,0x00,0x00, //139/ --> ‹
0x00,0x00,0x00,0x00,0x00,0x00, //140/ --> Œ
0x00,0x00,0x00,0x00,0x00,0x00, //141/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //142/ --> Ž
0x00,0x00,0x00,0x00,0x00,0x00, //143/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //144/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //145/ --> ‘
0x00,0x00,0x00,0x00,0x00,0x00, //146/ --> ’
0x00,0x00,0x00,0x00,0x00,0x00, //147/ --> “
0x00,0x00,0x00,0x00,0x00,0x00, //148/ --> ”
0x00,0x00,0x00,0x00,0x00,0x00, //149/ --> •
0x00,0x00,0x00,0x00,0x00,0x00, //150/ --> –
0x00,0x00,0x00,0x00,0x00,0x00, //151/ --> —
0x00,0x00,0x00,0x00,0x00,0x00, //152/ --> ˜
0x00,0x00,0x00,0x00,0x00,0x00, //153/ --> ™
0x00,0x00,0x00,0x00,0x00,0x00, //154/ --> š
0x00,0x00,0x00,0x00,0x00,0x00, //155/ --> ›
0x00,0x00,0x00,0x00,0x00,0x00, //156/ --> œ
0x00,0x00,0x00,0x00,0x00,0x00, //157/ --> 
0x00,0x00,0x00,0x00,0x00,0x00, //158/ --> ž
0x00,0x00,0x00,0x00,0x00,0x00, //159/ --> Ÿ
0x00,0x00,0x00,0x00,0x00,0x00, //160/ -->  
0x00,0x00,0x00,0x00,0x00,0x00, //161/ --> ¡
0x00,0x00,0x00,0x00,0x00,0x00, //162/ --> ¢
0x00,0x00,0x00,0x00,0x00,0x00, //163/ --> £
0x00,0x00,0x00,0x00,0x00,0x00, //164/ --> ¤
0x00,0x00,0x00,0x00,0x00,0x00, //165/ --> ¥
0x00,0x00,0x00,0x00,0x00,0x00, //166/ --> ¦
0x00,0x00,0x00,0x00,0x00,0x00, //167/ --> §
0x00,0x00,0x00,0x00,0x00,0x00, //168/ --> ¨
0x00,0x00,0x00,0x00,0x00,0x00, //169/ --> ©
0x00,0x00,0x00,0x00,0x00,0x00, //170/ --> ª
0x00,0x00,0x00,0x00,0x00,0x00, //171/ --> «
0x00,0x00,0x00,0x00,0x00,0x00, //172/ --> ¬
0x00,0x00,0x00,0x00,0x00,0x00, //173/ --> ­
0x00,0x00,0x00,0x00,0x00,0x00, //174/ --> ®
0x00,0x00,0x00,0x00,0x00,0x00, //175/ --> ¯
0x00,0x00,0x00,0x00,0x00,0x00, //176/ --> °
0x00,0x00,0x00,0x00,0x00,0x00, //177/ --> ±
0x00,0x00,0x00,0x00,0x00,0x00, //178/ --> ²
0x00,0x00,0x00,0x00,0x00,0x00, //179/ --> ³
0x00,0x00,0x00,0x00,0x00,0x00, //180/ --> ´
0x00,0x00,0x00,0x00,0x00,0x00, //181/ --> µ
0x00,0x00,0x00,0x00,0x00,0x00, //182/ --> ¶
0x00,0x00,0x00,0x00,0x00,0x00, //183/ --> ·
0x00,0x00,0x00,0x00,0x00,0x00, //184/ --> ¸
0x00,0x00,0x00,0x00,0x00,0x00, //185/ --> ¹
0x00,0x00,0x00,0x00,0x00,0x00, //186/ --> º
0x00,0x00,0x00,0x00,0x00,0x00, //187/ --> »
0x00,0x00,0x00,0x00,0x00,0x00, //188/ --> ¼
0x00,0x00,0x00,0x00,0x00,0x00, //189/ --> ½
0x00,0x00,0x00,0x00,0x00,0x00, //190/ --> ¾
0x00,0x00,0x00,0x00,0x00,0x00, //191/ --> ¿
0x00,0x00,0x00,0x00,0x00,0x00, //192/ --> À
0x00,0x00,0x00,0x00,0x00,0x00, //193/ --> Á
0x00,0x00,0x00,0x00,0x00,0x00, //194/ --> Â
0x00,0x00,0x00,0x00,0x00,0x00, //195/ --> Ã
0x00,0x00,0x00,0x00,0x00,0x00, //196/ --> Ä
0x00,0x00,0x00,0x00,0x00,0x00, //197/ --> Å
0x00,0x00,0x00,0x00,0x00,0x00, //198/ --> Æ
0x00,0x00,0x00,0x00,0x00,0x00, //199/ --> Ç
0x00,0x00,0x00,0x00,0x00,0x00, //200/ --> È
0x00,0x00,0x00,0x00,0x00,0x00, //201/ --> É
0x00,0x00,0x00,0x00,0x00,0x00, //202/ --> Ê
0x00,0x00,0x00,0x00,0x00,0x00, //203/ --> Ë
0x00,0x00,0x00,0x00,0x00,0x00, //204/ --> Ì
0x00,0x00,0x00,0x00,0x00,0x00, //205/ --> Í
0x00,0x00,0x00,0x00,0x00,0x00, //206/ --> Î
0x00,0x00,0x00,0x00,0x00,0x00, //207/ --> Ï
0x00,0x00,0x00,0x00,0x00,0x00, //208/ --> Ð
0x00,0x00,0x00,0x00,0x00,0x00, //209/ --> Ñ
0x00,0x00,0x00,0x00,0x00,0x00, //210/ --> Ò
0x00,0x00,0x00,0x00,0x00,0x00, //211/ --> Ó
0x00,0x00,0x00,0x00,0x00,0x00, //212/ --> Ô
0x00,0x00,0x00,0x00,0x00,0x00, //213/ --> Õ
0x00,0x00,0x00,0x00,0x00,0x00, //214/ --> Ö
0x00,0x00,0x00,0x00,0x00,0x00, //215/ --> ×
0x00,0x00,0x00,0x00,0x00,0x00, //216/ --> Ø
0x00,0x00,0x00,0x00,0x00,0x00, //217/ --> Ù
0x00,0x00,0x00,0x00,0x00,0x00, //218/ --> Ú
0x00,0x00,0x00,0x00,0x00,0x00, //219/ --> Û
0x00,0x00,0x00,0x00,0x00,0x00, //220/ --> Ü
0x00,0x00,0x00,0x00,0x00,0x00, //221/ --> Ý
0x00,0x00,0x00,0x00,0x00,0x00, //222/ --> Þ
0x00,0x00,0x00,0x00,0x00,0x00, //223/ --> ß
0x00,0x00,0x00,0x00,0x00,0x00, //224/ --> à
0x00,0x00,0x00,0x00,0x00,0x00, //225/ --> á
0x00,0x00,0x00,0x00,0x00,0x00, //226/ --> â
0x00,0x00,0x00,0x00,0x00,0x00, //227/ --> ã
0x00,0x00,0x00,0x00,0x00,0x00, //228/ --> ä
0x00,0x00,0x00,0x00,0x00,0x00, //229/ --> å
0x00,0x00,0x00,0x00,0x00,0x00, //230/ --> æ
0x00,0x00,0x00,0x00,0x00,0x00, //231/ --> ç
0x00,0x00,0x00,0x00,0x00,0x00, //232/ --> è
0x00,0x00,0x00,0x00,0x00,0x00, //233/ --> é
0x00,0x00,0x00,0x00,0x00,0x00, //234/ --> ê
0x00,0x00,0x00,0x00,0x00,0x00, //235/ --> ë
0x00,0x00,0x00,0x00,0x00,0x00, //236/ --> ì
0x00,0x00,0x00,0x00,0x00,0x00, //237/ --> í
0x00,0x00,0x00,0x00,0x00,0x00, //238/ --> î
0x00,0x00,0x00,0x00,0x00,0x00, //239/ --> ï
0x00,0x00,0x00,0x00,0x00,0x00, //240/ --> ð
0x00,0x00,0x00,0x00,0x00,0x00, //241/ --> ñ
0x00,0x00,0x00,0x00,0x00,0x00, //242/ --> ò
0x00,0x00,0x00,0x00,0x00,0x00, //243/ --> ó
0x00,0x00,0x00,0x00,0x00,0x00, //244/ --> ô
0x00,0x00,0x00,0x00,0x00,0x00, //245/ --> õ
0x00,0x00,0x00,0x00,0x00,0x00, //246/ --> ö
0x00,0x00,0x00,0x00,0x00,0x00, //247/ --> ÷
0x00,0x00,0x00,0x00,0x00,0x00, //248/ --> ø
0x00,0x00,0x00,0x00,0x00,0x00, //249/ --> ù
0x00,0x00,0x00,0x00,0x00,0x00, //250/ --> ú
0x00,0x00,0x00,0x00,0x00,0x00, //251/ --> û
0x00,0x00,0x00,0x00,0x00,0x00, //252/ --> ü
0x00,0x00,0x00,0x00,0x00,0x00, //253/ --> ý
0x00,0x00,0x00,0x00,0x00,0x00, //254/ --> þ
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF  //255/ --> ÿ
};
                     
#define DS      PORTC.0
#define ST_CP   PORTC.1
#define SH_CP   PORTC.2   
#define reset   PORTC.3  
#define LED_sel PORTD
#define DDR_DS      DDRC.0
#define DDR_ST_CP   DDRC.1
#define DDR_SH_CP   DDRC.2
#define DDR_reset   DDRC.3  
#define DDR_LED_sel DDRD  

#define def_lebar_karakter_display      16      //jumlah hurufr yang dapat ditampilkan
#define def_jum_kolom_perkarakter       6      //jumlah kolom dalam satu huruf
#define max_karakter                    200     //jumlah huruf yang dapat disimpan
#define jum_kol_semua_kar_disp          def_lebar_karakter_display*def_jum_kolom_perkarakter 
#define buff_kolom                      max_karakter*def_jum_kolom_perkarakter

int             LED_gotox;
unsigned int    jum_kolom_semua_karakter = jum_kol_semua_kar_disp,  
                lebar_karakter_display = def_lebar_karakter_display,
                jum_kolom_perkarakter = def_jum_kolom_perkarakter,
                jum_buffer_semua_data = buff_kolom;    
unsigned char   buffer[jum_kol_semua_kar_disp],        
                data_kata[max_karakter],               
                data_kata_semua_kolom[buff_kolom];     
                    
void  minimum_trigger_time()
{
    delay_us(100);
}
        
void LED_init()
{               
        DDR_LED_sel = 0xFF;
        DDR_DS    = 1;
        DDR_ST_CP = 1;        
        DDR_SH_CP = 1;
        DDR_reset = 1; 
        ST_CP = 0;
        SH_CP = 0;
        DS    = 0;    
        reset = 1;
        delay_ms(1);  
}                                 

unsigned char inverse_bit(unsigned char input_bit)
{
unsigned char data=0;
        data = input_bit ^ 0xFF;
        return(data);
}
                     
void pilih_segmen(unsigned char nilai_LED)
{           
unsigned char i=0;
        ST_CP = 0;     
        for(i=0;i<8;i++)
        {
                DS = (nilai_LED >> (7-i))&1;  
                delay_us(1);
                SH_CP = 1;   
                delay_us(1);
                SH_CP = 0;
                delay_us(1); 
        }       
        delay_us(1);
        ST_CP = 1;
        delay_us(2);
        ST_CP = 0;    
        delay_us(2);   
}     

void update_display(unsigned char kontras)
{                 
unsigned int    update_i =0,
                update_j =0;
unsigned char stat_kontras;
        stat_kontras = kontras;
        for(update_i=0;update_i < jum_kolom_perkarakter;update_i++)
        {
                pilih_segmen((unsigned int)pow(2,update_i));  
                switch(stat_kontras)
                {
                        case 0: LED_sel = inverse_bit(buffer[update_i]); 
                                break;
                        case 1: LED_sel = buffer[update_i]; 
                                break;
                }
                minimum_trigger_time();
                for(update_j=0;update_j < (lebar_karakter_display-1);update_j++)
                {
                        pilih_segmen(0);    
                        switch(stat_kontras)
                        {
                                case 0: LED_sel = inverse_bit(buffer[(update_i +((update_j + 1)*jum_kolom_perkarakter))]); 
                                        break;
                                case 1: LED_sel = buffer[(update_i +((update_j + 1)*jum_kolom_perkarakter))]; 
                                        break;
                        }
                        minimum_trigger_time();
                }  
        }
}  
void LED_clear()
{                 
unsigned int i=0;
        for(i=0;i<jum_buffer_semua_data;i++) 
        {
                data_kata_semua_kolom[i] = 0;
        }
}         
  
void LED_update_buffer()
{         
unsigned int    i,
                j,
                k,
                lebar_kata;
        lebar_kata = strlen(data_kata);
        k=0;     
        for(i=0;i<lebar_kata;i++) 
        {                                  
                for(j=0;j<jum_kolom_perkarakter;j++) 
                {
                        data_kata_semua_kolom[k] = font[(((unsigned int)data_kata[i])*jum_kolom_perkarakter)+j];
                        k++;     
                }           
        }   
}            
void LED_refreshrate( unsigned int delay_LED,unsigned char buff_kontras)
{             
unsigned int    m,
                n;
int             _gotox;
unsigned char   stat_buff_kontras;
        stat_buff_kontras = buff_kontras;
        _gotox = LED_gotox;     
        for(m=0;m<delay_LED;m++)
        {            
                for(n=0;n<jum_kolom_semua_karakter;n++)
                {                
                        if(_gotox < 0)
                                buffer[n] = data_kata_semua_kolom[n - _gotox]; 
                        else 
                                buffer[n + _gotox] = data_kata_semua_kolom[n];     
                }                        
                update_display(stat_buff_kontras); 
        }     
}

_______________________
DAFTAR PUSTAKA
protostack.com/blog/2010/05/introduction-to-74hc595-shift-register-controlling-16-leds/
arduino.cc/en/Tutorial/ShiftOut

12 Responses to LED Matrix Display

  1. harlan says:

    mau tanya gan..
    saya udah coba seperti tutorial di atas..
    tapi saya ganti dengan dot matrix 7×6 sebanyak 8 karakter..
    masalahnya sangat susah untuk mencari triger yang pas agar tulisannya bersih..
    mohon bantuannya gan,,

    • wangready says:

      iya gan, kalo di proteus kita harus setting jg trigger time dot matrix nya sesuai program….

      • harlan says:

        saya ada masalah lagi gan..
        jadi saya pake atmega 8535,nah krna ramnya kecil jadi maksimum karakternya saya kurangin jadi 47..
        jalan,tpi masalahnya ada bayangan karakternya..dan sangat mempengaruhi,bentuk tulisan jadi g jelas..mohon pencerahannya gan..

      • wangready says:

        kalo pengalaman saya ram yg gk cukup bisa jg jadi penyebabnya atau nilaio minimum trigger time yang ada pada led matrix coba diatur2 lg gan….

      • harlan says:

        agan udah tes pake atmega32?mksud ane yang bkan proteus..
        soalnya kalau jalan,ane ganti atmega32..
        karna programnya bagus bgt..ane tgl input tulisannya aja..
        hahaha..pengen tutorial nih gan:)

        oya,skalian nanya gan..program tuk ngirim sms pake atmega dengan koneksi modem ada g gan?buntu nih nyarinya kmana-mana, g nemu yang pake modem biasa,yg ada cma modem fasttrack..
        thx ya gan..

      • wangready says:

        ane baru nyoba pake proteus, selain itu gk ada gan

  2. harlan says:

    ane dah ganti pake atmega32 gan, hasilnya tetap sama, ada bayangan yang telat 1 karakter muculnya..jadi hurufnya jadi rusak..
    waktu karakter pertama mucul di sebelah kanan, di paling ujung kiri ada bayangan yang muncul..
    gmn nih gan, tolong ane..tuk tugas akhir ane..

  3. harlan says:

    mksudnya max huruf yang mana gan?

  4. alikset says:

    Hallo gan ,
    saya pemula ini

    coba progamnya itu langsung saya copy paste ke AVR lalu di compale kok ada error 19 yaa,
    minta bantuannya ,
    terimakasih

    Setiawan_alik@yahoo.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s