Mạch Khóa Số Điện Tử Mạch Đếm Sản Phẩm Mạch Đèn giao thông Ngã Tư Mạch Trái Tim Final Mạch Trái Tim Final Mạch Trái Tim I Love U

September 11, 2013

Matrix 8x8 3 màu code C - Chạy Chữ


Code:


#include<reg52.h>
#include<string.h>

void delay(int t)
{
 int a;
 for(a=0;a<t;a++)
 {}
}
 int m,n,p;
unsigned char code cot[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
 unsigned char code ma1[]={
           
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0xFE,0x82,0x82,0x82,0x44,0x38,0x00,0x00,  //    D
0x7C,0x82,0x82,0x82,0x82,0x7C,0x00,0x00,  //   O
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF8,0x14,0x12,0x12,0x14,0xF8,0x00,0x00,  //   A
0xFE,0x04,0x08,0x10,0x20,0xFE,0x00,0x00,  //   N
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFE,0x04,0x08,0x10,0x08,0x04,0xFE,0x00,  //   M
0x7C,0x82,0x82,0x82,0x82,0x7C,0x00,0x00,  //   O
            0xFE,0x04,0x08,0x10,0x20,0xFE,0x00,0x00,  //   N
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7C,0x82,0x82,0x82,0x82,0x7C,0x00,0x00,  //   O
0xFE,0x32,0x32,0x52,0x8C,0x00,0x00,0x00,  //   R
0x7C,0x82,0x82,0x82,0x82,0x44,0x00,0x00,  //   C
0xF8,0x14,0x12,0x12,0x14,0xF8,0x00,0x00,  //   A
0xFE,0x82,0x82,0x82,0x44,0x38,0x00,0x00,  //   D
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
},
ma2[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x4C,0x92,0x92,0x92,0x64,0x00,0x00,0x00,  //   S
    0x88,0xFA,0x80,0x00,0x00,0x00,0x00,0x00,  //   i
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
    0xFE,0x10,0x08,0x08,0xF0,0x00,0x00,0x00,  //   h
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x3C,0x40,0x80,0x40,0x3C,0x00,0x00,0x00,  //   v
    0x88,0xFA,0x80,0x00,0x00,0x00,0x00,0x00,  //   i
    0x70,0xA8,0xA4,0xA4,0x18,0x00,0x00,0x00,  //   e
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x08,0x7E,0x88,0x48,0x00,0x00,0x00,0x00,  //   t
    0xFE,0x10,0x08,0x08,0xF0,0x00,0x00,0x00,  //   h
    0x78,0x80,0x80,0x80,0x78,0x00,0x00,0x00,  //   u
    0x78,0x84,0x84,0x84,0x48,0x00,0x00,0x00,  //   c
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFE,0x10,0x08,0x08,0xF0,0x00,0x00,0x00,  //   h
    0x88,0xFA,0x80,0x00,0x00,0x00,0x00,0x00,  //   i
    0x70,0xA8,0xA4,0xA4,0x18,0x00,0x00,0x00,  //   e
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
},
ma3[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFE,0x82,0x82,0x82,0x44,0x38,0x00,0x00,  //    D
    0x78,0x84,0x84,0x84,0x78,0x00,0x00,0x00,  //   o
    0x60,0x94,0x94,0x94,0xF8,0x00,0x00,0x00,  //   a
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x02,0x02,0xFE,0x02,0x02,0x00,0x00,0x00,  //   T
    0xFE,0x10,0x08,0x08,0xF0,0x00,0x00,0x00,  //   h
    0x70,0xA8,0xA4,0xA4,0x18,0x00,0x00,0x00,  //   e
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFE,0x10,0x10,0x10,0x10,0xFE,0x00,0x00,  //   H
    0x78,0x80,0x80,0x80,0x78,0x00,0x00,0x00,  //   u
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
    0x98,0xA4,0xA4,0xA4,0x78,0x00,0x00,0x00,  //   g
    0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x00,  //   -
    0x1E,0x20,0x40,0x80,0x40,0x20,0x1E,0x00,  //   V
    0x78,0x80,0x80,0x80,0x78,0x00,0x00,0x00,  //   u
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x1E,0x20,0x40,0x80,0x40,0x20,0x1E,0x00,  //   V
    0x60,0x94,0x94,0x94,0xF8,0x00,0x00,0x00,  //   a
    0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,  //   n
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFE,0x82,0x82,0x82,0x44,0x38,0x00,0x00,  //    D
    0x78,0x80,0x80,0x80,0x78,0x00,0x00,0x00,  //   u
    0x78,0x84,0x84,0x84,0x48,0x00,0x00,0x00,  //   c  
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
 

void matrix1()
{
 P3=0xff;

 for(m=0;m<16*8;m++)
 {
 for(n=0;n<40;n++)
 {
 for(p=0;p<8;p++)
 {
  P0=cot[p];
  P1=~ma1[m+p];
  delay(10);
   P1=0XFF;
  P0=0xff; delay(10);
 }
}
}
}

void matrix2()
{
 int i,j,k;
 P1=0xff;
 for(k=0;k<20*8;k++)
 {
 for(i=0;i<40;i++)
 {
 for(j=0;j<8;j++)
 {
  P0=cot[j];
  P3=~ma2[k+j];
 
  delay(10); P0=0XFF;
  P3=0xff; delay(10);
 }
}
}
}

void matrix3()
{
 int a,b,c;
 for(a=0;a<25*8;a++)
 {
 for(b=0;b<40;b++)
 {
 for(c=0;c<8;c++)
 {
  P0=cot[c];
  P1=P3=~ma3[a+c];
 
  delay(10); P3=0XFF;P0=0xff; P1=0xff;delay(10);
 }
}
}
}

void main()
{
 while(1)
 {
  matrix1();
  delay(10000);
  matrix2();
  delay(10000);
  matrix3();
  delay(10000);
 }
}

( File Mô Phỏng +code)

Echipkool - Chia sẻ kiến thức - Kết nối đam mê điện tử

0 comments:

Post a Comment

Bạn đọc hãy giúp chúng tôi xây dựng cộng đồng bằng cách để lại bình luận, chúng tôi luôn đón nhận mọi ý kiến của các bạn:
» Bình luận nghiêm túc và không chứa các liên kết quảng cáo.
» Vui lòng không Spam nhận xét với mọi hình thức.
» Rất mong bạn đề tên cho nhận xét của chính mình - Bằng cách chọn vào Tên/URL và điền tên bạn vào (Phần URL có thể bỏ trống ).

- Bạn có thể chèn Link nhạc (NCT), video(Youtube),Hình ảnh vào comment bằng cú pháp:
+ [youtube] Link video Youtube [/youtube].
+ [img] Link ảnh( định dạng PNG, JPG,GIF) [/img]
+Chèn link liên kết: <a href="LINK" rel="nofollow">Name</a>
-Bạn copy mã bên cạnh biểu tượng chèn vào nhận xét để bày tỏ cảm xúc!!

:) :( :)) :(( =)) =D> :D :P