Hiển thị các bài đăng có nhãn dịch led. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn dịch led. Hiển thị tất cả bài đăng

LED Matrix hiển thị trái tim dịch từ dưới lên trên





// PIC16F887 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON       // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF      // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF       // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF        // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)

// CONFIG2
#pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF        // Flash Program Memory Self Write Enable bits (Write protection off)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>


#define _XTAL_FREQ 4000000
const unsigned char choncot[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
const unsigned char maled[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                        0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
                        0x7F,0x3F,0x3F,0x7F,0x7F,0x3F,0x3F,0x7F,
                        0x3F,0x1F,0x1F,0x3F,0x3F,0x1F,0x1F,0x3F,
                        0x1F,0x0F,0x0F,0x1F,0x1F,0x0F,0x0F,0x1F,
                        0x8F,0x07,0x07,0x0F,0x0F,0x07,0x07,0x8F,
                        0xC7,0x83,0x03,0x07,0x07,0x03,0x83,0xC7,
                        0xE3,0xC1,0x81,0x03,0x3,0x81,0xC1,0xE3,
                        0xF1,0xE0,0xC0,0x81,0x81,0xC0,0xE0,0xF1,
                        0xF8,0xF0,0xE0,0xC0,0xC0,0xE0,0xF0,0xF8,
                        0xFC,0xF8,0xF0,0xE0,0xE0,0xF0,0xF8,0xFC,
                        0xFE,0xFC,0xF8,0xF0,0xF0,0xF8,0xFC,0xFE,
                        0xFF,0xFE,0xFC,0xF8,0xF8,0xFC,0xFE,0xFF,
                        0xFF,0xFF,0xFE,0xFC,0xFC,0xFE,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFE,0xFE,0xFF,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                        0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
};
const unsigned char maled1[]={
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
    0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
    0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
    0xFF,0x7F,0x7F,0xFF,0xFF,0x7F,0x7F,0xFF,
};
int i=0;
int j=0;
int dat=0;
void delay(void)
{
    __delay_ms(5);
}
void main(void)
{
    ANSEL=0x00;
    ANSELH=0x00;
    TRISB=0;
    TRISC=0;
//    TRISD=0;
    dat=0;
    while(1)
    {

        if(dat>=136)
        {
            dat=0;
        }
        for(j=0;j<=10;j++)
        {
            for(i=0;i<=7;i++)
            {
                PORTC=choncot[i];
//                PORTD=choncot[i];
                PORTB=maled[dat+i];
//                PORTB=maled1[dat+i];
                RB3=RB4=0;
                TRISD=0;
                PORTD=choncot[i];
                delay();                    
            }
            //}
           
        }
            dat=dat+8;
       
    }
}