Thông báo

Collapse
No announcement yet.

Lập trình C Led Matrix PIC18F4550???

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

  • Lập trình C Led Matrix PIC18F4550???

    Biên dịch báo lỗi ở: "for(i=0;i<strlen(chuoi);i++)". Các anh tìm ng.nhân giúp e vs..

    #include <p18f4550.h>
    #include <delays.h>
    #include <string.h>

    void getcode();
    void delay(int t);

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

    unsigned char cot[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,},
    hang[]={
    0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00, // 0x20,32,space
    0x00,0x30,0x7D,0x30,0x80,0x00,0x00,0x00, // 0x21,33,!
    0x70,0x60,0x00,0x70,0xE0,0x00,0x00,0x00, // 0x22,34,"
    0x12,0x3F,0x12,0x3F,0x92,0x00,0x00,0x00, // 0x23,35,#
    0x12,0x6A,0x2B,0xA4,0x80,0x00,0x00,0x00, // 0x24,36,$
    0x63,0x64,0x08,0x13,0xE3,0x00,0x00,0x00, // 0x25,37,%
    0x36,0x49,0x35,0x02,0x85,0x00,0x00,0x00, // 0x26,38,&
    0x00,0x70,0x60,0x80,0x80,0x00,0x00,0x00, // 0x27,39,'
    0x00,0x3E,0x41,0x80,0x80,0x00,0x00,0x00, // 0x28,40,(
    0x00,0x41,0x3E,0x80,0x80,0x00,0x00,0x00, // 0x29,41,)
    0x08,0x3E,0x1C,0x3E,0x88,0x00,0x00,0x00, // 0x2A,42,*
    0x08,0x08,0x3E,0x08,0x88,0x00,0x00,0x00, // 0x2B,43,+
    0x00,0x02,0x03,0x80,0x80,0x00,0x00,0x00, // 0x2C,44,,
    0x08,0x08,0x08,0x08,0x88,0x00,0x00,0x00, // 0x2D,45,-
    0x00,0x03,0x03,0x80,0x80,0x00,0x00,0x00, // 0x2E,46,.
    0x02,0x04,0x08,0x10,0xA0,0x00,0x00,0x00, // 0x2F,47,/
    0x3E,0x45,0x49,0x51,0xBE,0x00,0x00,0x00, // 0x30,48,0
    0x00,0x21,0x7F,0x81,0x80,0x00,0x00,0x00, // 0x31,49,1
    0x23,0x45,0x49,0x49,0xB1,0x00,0x00,0x00, // 0x32,50,2
    0x22,0x49,0x49,0x49,0xB6,0x00,0x00,0x00, // 0x33,51,3
    0x0C,0x14,0x24,0x7F,0x84,0x00,0x00,0x00, // 0x34,52,4
    0x7A,0x49,0x49,0x49,0xC6,0x00,0x00,0x00, // 0x35,53,5
    0x1E,0x29,0x49,0x49,0x86,0x00,0x00,0x00, // 0x36,54,6
    0x40,0x47,0x48,0x50,0xE0,0x00,0x00,0x00, // 0x37,55,7
    0x36,0x49,0x49,0x49,0xB6,0x00,0x00,0x00, // 0x38,56,8
    0x30,0x49,0x49,0x4A,0xBC,0x00,0x00,0x00, // 0x39,57,9
    0x00,0x1B,0x1B,0x80,0x80,0x00,0x00,0x00, // 0x3A,58,:
    0x00,0x1B,0x1B,0x80,0x80,0x00,0x00,0x00, // 0x3B,59,;
    0x08,0x14,0x22,0xC1,0x80,0x00,0x00,0x00, // 0x3C,60,<
    0x12,0x12,0x12,0x12,0x92,0x00,0x00,0x00, // 0x3D,61,=
    0x00,0x41,0x22,0x14,0x88,0x00,0x00,0x00, // 0x3E,62,>
    0x20,0x40,0x4D,0x48,0xB0,0x00,0x00,0x00, // 0x3F,63,?
    0x3E,0x41,0x5D,0x55,0xBC,0x00,0x00,0x00, // 0x40,64,@
    0x3F,0x44,0x44,0x44,0xBF,0x00,0x00,0x00, // 0x41,65,A
    0x7F,0x49,0x49,0x49,0xB6,0x00,0x00,0x00, // 0x42,66,B
    0x3E,0x41,0x41,0x41,0xA2,0x00,0x00,0x00, // 0x43,67,C
    0x7F,0x41,0x41,0x41,0xBE,0x00,0x00,0x00, // 0x44,68,D
    0x7F,0x49,0x49,0x49,0xC1,0x00,0x00,0x00, // 0x45,69,E
    0x7F,0x48,0x48,0x48,0xC0,0x00,0x00,0x00, // 0x46,70,F
    0x3E,0x41,0x49,0x49,0xAF,0x00,0x00,0x00, // 0x47,71,G
    0x7F,0x08,0x08,0x08,0xFF,0x00,0x00,0x00, // 0x48,72,H
    0x41,0x7F,0xC1,0x80,0x80,0x00,0x00,0x00, // 0x49,73,I
    0x06,0x01,0x01,0x01,0xFE,0x00,0x00,0x00, // 0x4A,74,J
    0x7F,0x08,0x14,0x22,0xC1,0x00,0x00,0x00, // 0x4B,75,K
    0x7F,0x01,0x01,0x01,0x81,0x00,0x00,0x00, // 0x4C,76,L
    0x7F,0x20,0x10,0x20,0xFF,0x00,0x00,0x00, // 0x4D,77,M
    0x7F,0x20,0x10,0x08,0xFF,0x00,0x00,0x00, // 0x4E,78,N
    0x3E,0x41,0x41,0x41,0xBE,0x00,0x00,0x00, // 0x4F,79,O
    0x7F,0x48,0x48,0x48,0xB0,0x00,0x00,0x00, // 0x50,80,P
    0x3E,0x41,0x45,0x42,0xBD,0x00,0x00,0x00, // 0x51,81,Q
    0x7F,0x48,0x48,0x4C,0xB3,0x00,0x00,0x00, // 0x52,82,R
    0x32,0x49,0x49,0x49,0xA6,0x00,0x00,0x00, // 0x53,83,S
    0x40,0x40,0x7F,0x40,0xC0,0x00,0x00,0x00, // 0x54,84,T
    0x7E,0x01,0x01,0x01,0xFE,0x00,0x00,0x00, // 0x55,85,U
    0x7C,0x02,0x01,0x02,0xFC,0x00,0x00,0x00, // 0x56,86,V
    0x7E,0x01,0x1E,0x01,0xFE,0x00,0x00,0x00, // 0x57,87,W
    0x63,0x14,0x08,0x14,0xE3,0x00,0x00,0x00, // 0x58,88,X
    0x70,0x08,0x07,0x08,0xF0,0x00,0x00,0x00, // 0x59,89,Y
    0x47,0x49,0x51,0xE1,0x80,0x00,0x00,0x00, // 0x5A,90,Z
    0x7F,0x41,0xC1,0x80,0x80,0x00,0x00,0x00, // [
    0x20,0x10,0x08,0x04,0x82,0x00,0x00,0x00, // '\'
    0x41,0x41,0x7F,0x80,0x80,0x00,0x00,0x00, // ]
    0x10,0x20,0x40,0x20,0x90,0x00,0x00,0x00, // ^
    0x01,0x01,0x01,0x01,0x81,0x00,0x00,0x00, // _
    0x40,0x20,0x10,0x80,0x80,0x00,0x00,0x00, // `
    0x02,0x15,0x15,0x15,0x8F,0x00,0x00,0x00, // 0x61,97,a
    0x7F,0x09,0x11,0x11,0x8E,0x00,0x00,0x00, // 0x62,98,b
    0x0E,0x11,0x11,0x11,0x82,0x00,0x00,0x00, // 0x63,99,c
    0x0E,0x11,0x11,0x09,0xFF,0x00,0x00,0x00, // 0x64,100,d
    0x0E,0x15,0x15,0x15,0x8C,0x00,0x00,0x00, // 0x65,101,e
    0x08,0x3F,0x48,0x40,0xA0,0x00,0x00,0x00, // 0x66,102,f
    0x08,0x15,0x15,0x15,0x9E,0x00,0x00,0x00, // 0x67,103,g
    0x7F,0x08,0x10,0x10,0x8F,0x00,0x00,0x00, // 0x68,104,h
    0x11,0x5F,0x81,0x80,0x80,0x00,0x00,0x00, // 0x69,105,i
    0x02,0x01,0x11,0xDE,0x80,0x00,0x00,0x00, // 0x6A,106,j
    0x7F,0x04,0x0A,0x91,0x80,0x00,0x00,0x00, // 0x6B,107,k
    0x41,0x7F,0x81,0x80,0x80,0x00,0x00,0x00, // 0x6C,108,l
    0x1F,0x10,0x0C,0x10,0x8F,0x00,0x00,0x00, // 0x6D,109,m
    0x1F,0x08,0x10,0x10,0x8F,0x00,0x00,0x00, // 0x6E,110,n
    0x0E,0x11,0x11,0x11,0x8E,0x00,0x00,0x00, // 0x6F,111,o
    0x1F,0x14,0x14,0x14,0x88,0x00,0x00,0x00, // 0x70,112,p
    0x08,0x14,0x14,0x12,0x9F,0x00,0x00,0x00, // 0x71,113,q
    0x1F,0x08,0x10,0x10,0x88,0x00,0x00,0x00, // 0x72,114,r
    0x09,0x15,0x15,0x15,0x82,0x00,0x00,0x00, // 0x73,115,s
    0x10,0x7E,0x11,0x01,0x82,0x00,0x00,0x00, // 0x74,116,t
    0x1E,0x01,0x01,0x02,0x9F,0x00,0x00,0x00, // 0x75,117,u
    0x1C,0x02,0x01,0x02,0x9C,0x00,0x00,0x00, // 0x76,118,v
    0x1E,0x01,0x06,0x01,0x9E,0x00,0x00,0x00, // 0x77,119,w
    0x11,0x0A,0x04,0x0A,0x91,0x00,0x00,0x00, // 0x78,120,x
    0x18,0x05,0x05,0x05,0x9E,0x00,0x00,0x00, // 0x79,121,y
    0x11,0x13,0x15,0x19,0x91,0x00,0x00,0x00 // 0x7A,122,z
    };

    unsigned char chuoi[]="Duong"; // Khai bao chuoi can hien thi
    unsigned char mang[17]; // Khai bao mang chua ma led cua ky tu tuc thoi
    int i,j,k,m;
    void getcode() // Ham lay ma led cho ky tu
    {
    mang[0]=hang[chuoi[i]*8];
    mang[1]=hang[chuoi[i]*8+1];
    mang[2]=hang[chuoi[i]*8+2];
    mang[3]=hang[chuoi[i]*8+3];
    mang[4]=hang[chuoi[i]*8+4];
    mang[5]=hang[chuoi[i]*8+5];
    mang[6]=hang[chuoi[i]*8+6];
    mang[7]=hang[chuoi[i]*8+7];

    mang[8]=hang[chuoi[(i+1)]*8];
    mang[9]=hang[chuoi[(i+1)]*8+1];
    mang[10]=hang[chuoi[(i+1)]*8+2];
    mang[11]=hang[chuoi[(i+1)]*8+3];
    mang[12]=hang[chuoi[(i+1)]*8+4];
    mang[13]=hang[chuoi[(i+1)]*8+5];
    mang[14]=hang[chuoi[(i+1)]*8+6];
    mang[15]=hang[chuoi[(i+1)]*8+7];
    }

    void main()
    { TRISC=0x00;TRISD=0x00;
    while(1)
    {
    for(i=0;i<strlen(chuoi);i++)
    {
    getcode(); // Lay ma led
    for(j=0;j<8;j++) // 8 ma cua ky tu
    {
    for(k=0;k<20;k++) // Tao tre
    { for(m=0;m<8;m++); // Quet tu cot 1 toi cot 8
    {
    PORTC=cot[m];
    PORTD=mang[m+j];
    delay(1);
    PORTC=0x00; // Xoa led tranh hien tuong bong ma
    }
    }
    }
    }
    }
    }

Về tác giả

Collapse

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

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

Collapse

Đang tải...
X