/*****************************************************
This program was produced by the
CodeWizardAVR V2.03.4 Standard
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 2011-09-01
Author  : 
Company : 
Comments: µµÆ® ¸ÅÆ®¸¯½º ±âº»µ¿ÀÛ ±¸Çö 

10p µ¥ÀÌÅÍ ÄÉÀ¸ºí ¿¬°á½Ã ¾Æ·¡¿Í °°ÀÌ ¿¬°áÇØÁÖ¼¼¿ä!

AVR-ATmega2560È®ÀåÇü °³¹ßº¸µå  PORTC <-------------> µµÆ®¸ÅÆ®¸¯½º ¸ðµâ - 10p¹Ú½ºÄ¿³ØÅÍ(PORT0)
AVR-ATmega2560È®ÀåÇü °³¹ßº¸µå  PORTD <-------------> µµÆ®¸ÅÆ®¸¯½º ¸ðµâ - 10p¹Ú½ºÄ¿³ØÅÍ(PORT1)

Chip type           : ATmega128
Program type        : Application
Clock frequency     : 16.000000 MHz
Memory model        : Small
External RAM size   : 0
Data Stack size     : 1024
*****************************************************/

#include <mega2560.h>
#include <delay.h>

char vertical[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
char english[28][8]={
0xe7,0xdb,0xbd,0xbd,0x81,0xbd,0xbd,0xbd,     // A
0xc1,0xbd,0xbd,0xc1,0xdd,0xbd,0xbd,0xc1,     // B
0xc3,0xbd,0xfd,0xfd,0xfd,0xbd,0xbd,0xc3,     // C
0xc1,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xc1,     // D
0x81,0xfd,0xfd,0x81,0xfd,0xfd,0xfd,0x81,     // E
0x81,0xfd,0xfd,0x81,0xfd,0xfd,0xfd,0xfd,     // F
0xe7,0xd9,0xbd,0xfd,0x8d,0xbd,0xdb,0xe7,     // G
0xbd,0xbd,0xbd,0x81,0xbd,0xbd,0xbd,0xbd,     // H
0xc3,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xc3,     // I
0xc3,0xe7,0xe7,0xe7,0xe7,0xe5,0xf5,0xfb,     // J
0xdd,0xed,0xf5,0xf9,0xf5,0xed,0xdd,0xbd,     // K
0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0x81,     // L
0xbd,0x99,0xa5,0xa5,0xa5,0xbd,0xbd,0xbd,     // M
0xbd,0xbd,0xb9,0xb5,0xad,0x9d,0xbd,0xbd,     // N
0xe7,0xdb,0xbd,0xbd,0xbd,0xbd,0xdb,0xe7,     // O
0xe1,0xdd,0xdd,0xdd,0xe1,0xfd,0xfd,0xfd,     // P
0xe3,0xdd,0xdd,0xdd,0xd5,0xcd,0xc3,0xbf,     // Q
0xc1,0xbd,0xbd,0xc1,0xdd,0xbd,0xbd,0xbd,     // R
0xc3,0xbd,0xfd,0xc3,0xbf,0xbf,0xbd,0xc3,     // S
0x81,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,     // T
0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xc3,     // U
0xbd,0xbd,0xbd,0xbd,0xbd,0xbd,0xdb,0xe7,     // V
0xbd,0xbd,0xbd,0xbd,0xa5,0xa5,0xa5,0x99,     // W
0xbd,0xbd,0xd9,0xe7,0xe7,0xdb,0xbd,0xbd,     // X
0xbd,0xbd,0xbd,0xdb,0xe7,0xe7,0xe7,0xe7,     // Y
0x81,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x81,     // Z
};
int Toggle=0;
int num_cnt=0;
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
 static int cnt=0;
 cnt++;
 if(cnt==500)
 {
    num_cnt++;
    cnt=0;         
    if(num_cnt==27)
    {   
        Toggle++;
            if(Toggle==3)
            Toggle=0;
        num_cnt=0;
        }
    }

TCNT0+=6;
}

void main(void)
{
    //--ÀÔÃâ·Â Æ÷Æ® ÃÊ±âÈ­! 
    PORTC=0xFF;
    DDRC=0xFF;       
    
    PORTD=0xFF;
    DDRD=0xFF;
              
    TCCR0A=0x00;//Normal Mode Operation(Overflow Interrupt Enable) 
    TCCR0B=0x03;//64Prescale Select
    TCNT0=0x06;// Timer/Count Register initialization

    TIMSK0=0x01;// Timer(s)/Counter(s) Interrupt(s) initialization
    #asm("sei")// Global enable interrupts
while(1)
{
    int i=0;
    static int j=0;  
    for(i=0;i<8;i++)
    {
        switch(Toggle)
        {
            case 0:
            //Ã¹Â°--Orange LED ¼ÂÆÃ ¶óÀÎ(Horizontal) 
            PORTD=0XFE;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í 
            PORTC=english[num_cnt][i];
            PORTD=0XFF;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
             
            //µÎ¹øÂ° Red LED ¼ÂÆÃ ¶óÀÎ(Horizontal)    
            PORTD=0XFD;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=0XFF;
            PORTD=0XFF;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
            //°øÅë TR ±¸µ¿ ¶óÀÎ 
            //--------------------------------------------------
           
            //¼¼·Î °øÅë ¶óÀÎ(Vertical) 
            PORTD=0XFB;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=vertical[i];
            PORTD=0XFF;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
            delay_ms(1); //1ms°£°Ý ´ÙÀÌ³»¹Í µð½ºÇÃ·¹ÀÌ      
            break;  
                  
            case 1:
                //°¡·Î----------------------------------------------
            //Ã¹Â° LED ¼ÂÆÃ ¶óÀÎ 
            PORTD=0XFE;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í 
            PORTC=0xff;
            PORTD=0XFF;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
               
             
            //µÎ¹øÂ° LED ¼ÂÆÃ ¶óÀÎ   
            PORTD=0XFD;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=english[num_cnt][i];
            PORTD=0XFF;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
               


             //¼¼·Î °øÅë ¶óÀÎ(Vertical) 
            PORTD=0XFB;             //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=vertical[i];
            PORTD=0XFF;             //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý 
            delay_ms(1);             //1ms°£°Ý ´ÙÀÌ³»¹Í µð½ºÇÃ·¹ÀÌ  
            //----------------------------------------------
            break;  
            
            case 2:
                //°¡·Î----------------------------------------------
            //Ã¹Â° LED ¼ÂÆÃ ¶óÀÎ 
            PORTD=0XFE;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í 
            PORTC=english[num_cnt][i];
            PORTD=0XFF;//74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
               
             
            //µÎ¹øÂ° LED ¼ÂÆÃ ¶óÀÎ   
            PORTD=0XFD;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=english[num_cnt][i];
            PORTD=0XFF;                 //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý
               


             //¼¼·Î °øÅë ¶óÀÎ(Vertical) 
            PORTD=0XFB;             //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ LOW ¹öÆÛ ¿­°í
            PORTC=vertical[i];
            PORTD=0XFF;             //74HC574 ±¸µ¿ Å¬·° ½ÅÈ£ HIGH ¹öÆÛ Àá±Ý 
            delay_ms(1);             //1ms°£°Ý ´ÙÀÌ³»¹Í µð½ºÇÃ·¹ÀÌ  
            //----------------------------------------------
            break;
        }
    }  

  }
}
