Thông báo

Collapse
No announcement yet.

giúp em cái code này

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • giúp em cái code này

    #include<reg52.h>

    // Khai bao 1 so chan dieu khien 74595 va 74154
    sbit SCK=P1^0; // chan 11 cua 595
    sbit STR=P1^1; // chan 12
    sbit SDA=P1^2; // chan 14
    sbit ctrl=P3^0; // dieu khien chan "Enable" cua 74154

    /*-----------------------------------------------------------------------------------------------
    Layer0
    -----------------------------------------------------------------------------------------------*/
    const unsigned char code cot[]=
    {
    /*-----------------------------------------------------------------------------------------------
    Hexa C code for ledmatrix
    Text content: "THANH HUNG"
    Code generated by the LedTECHPAL software
    Width x Height(pixels):100x16
    Size of data: 208 (byte)
    Position of region(X:Y):0:0
    -----------------------------------------------------------------------------------------------*/
    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, 0xFF, 0xF7, 0x82, 0x3C, 0x7F, 0x78,
    0x7B, 0xDE, 0xFE, 0x39, 0xE8, 0x00, 0x00, 0xD9, 0x63, 0x07, 0x0C, 0x26, 0x30, 0x31, 0x8C, 0x26,
    0x13, 0x98, 0x00, 0x00, 0x18, 0x63, 0x07, 0x0E, 0x26, 0x30, 0x31, 0x8C, 0x27, 0x13, 0x08, 0x00,
    0x00, 0x18, 0x63, 0x05, 0x0B, 0x26, 0x30, 0x31, 0x8C, 0x25, 0x96, 0x00, 0x00, 0x00, 0x18, 0x7F,
    0x09, 0x89, 0xA7, 0xF0, 0x3F, 0x8C, 0x24, 0xD6, 0x3C, 0x00, 0x00, 0x18, 0x63, 0x0F, 0x89, 0xA6,
    0x30, 0x31, 0x8C, 0x24, 0xD6, 0x18, 0x00, 0x00, 0x18, 0x63, 0x18, 0xC8, 0xE6, 0x30, 0x31, 0x8C,
    0x24, 0x73, 0x18, 0x00, 0x00, 0x18, 0x63, 0x10, 0xC8, 0x66, 0x30, 0x31, 0x86, 0x64, 0x33, 0x98,
    0x00, 0x00, 0x3C, 0xF7, 0xB9, 0xFC, 0x2F, 0x78, 0x7B, 0xC7, 0xCE, 0x10, 0xF8, 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,

    };







    void delay(int t) // ham tao tre
    {
    int a,b;
    for(a=0;a<t;a++)
    {
    for(b=0;b<125;b++);
    }
    }


    void quet(unsigned char d) // Ham xu ly 595-chuyen du lieu song song sang noi tiep
    {
    unsigned char i,t;
    for(i=0;i<8;i++)
    {
    t=d&0x80;
    if(t==0x80)
    SDA=1;
    else SDA=0;
    d=d<<1;
    SCK=0;
    SCK=1;
    }
    }
    unsigned char buffer(unsigned char x,unsigned char y,char i) // Ham xu ly du lieu hang
    {
    unsigned char temp;
    temp=(x<<i)|(y>>(8-i));
    return temp;
    }
    char i,j,k,m; // Khai bao cac bien quet led

    void main()
    {
    P3=0x00;
    while(1)
    {
    for(k=0;k<64-8;k++) // 64 la kich thuoc cot cua mang "cot",8 la so led matrix
    {
    for(i=0;i<8;i++) // Xu ly tung bit
    {
    for(j=0;j<10;j++) // vong lap tao tre
    {
    for(m=0;m<16;m++) // Quet tung hang
    {
    quet(buffer(cot[m*64+k+7],cot[m*64+k+8],i)); // Ma cho led 8
    quet(buffer(cot[m*64+k+6],cot[m*64+k+7],i)); //Ma cho led 7
    quet(buffer(cot[m*64+k+5],cot[m*64+k+6],i));
    quet(buffer(cot[m*64+k+4],cot[m*64+k+5],i));
    quet(buffer(cot[m*64+k+3],cot[m*64+k+4],i)); // "m*64": 64 la so cot cua mang
    quet(buffer(cot[m*64+k+2],cot[m*64+k+3],i));
    quet(buffer(cot[m*64+k+1],cot[m*64+k+2],i));
    quet(buffer(cot[m*64+k],cot[m*64+k+1],i)); // Ma cho led 1
    STR=0; // Xung chot 64bit du lieu
    STR=1;
    P2=m;
    delay(2); // tre 1 khoang
    ctrl=1; // Cam IC 74154
    ctrl=0; // Cho phep IC 74154 hoat dong
    }
    }
    }
    }
    }
    }



    câu lệnh này thấy kỳ kỳ
    unsigned char buffer(unsigned char x,unsigned char y,char i) // Ham xu ly du lieu hang
    {
    unsigned char temp;
    temp=(x<<i)|(y>>(8-i));
    return temp;
    }

Về tác giả

Collapse

hell1410 Tìm hiểu thêm về hell1410

Bài viết mới nhất

Collapse

Đang tải...
X