Chào các bạn trong bài đăng này mình sẽ hướng dẫn các bạn về matrix 5x7 với 8051 cụ thể là đếm từ 0 - 9.
- Đây là ảnh mô phỏng protues.
- Đây là code chương trình.
#include"main.h"
#include"..\lib\delay.h"
unsigned char code Font5x7[10][7]={{0x0E,0x11,0x13,0x15,0x19,0x11,0x0E}, // Font cua so 0
{0x1F, 0x04, 0x04, 0x04, 0x14, 0x0C, 0x04}, // Font cua so 1
{0x1F, 0x08, 0x04, 0x02, 0x01, 0x11, 0x0E},
{0x0E, 0x11, 0x01, 0x06, 0x01, 0x11, 0x0E},
{0x02, 0x1F, 0x12, 0x08, 0x04, 0x02, 0x01},
{0x1E, 0x01, 0x01, 0x01, 0x1E, 0x10, 0x1F},
{0x0E, 0x11, 0x11, 0x1E, 0x10, 0x11, 0x0E},
{0x04, 0x04, 0x04, 0x02, 0x01, 0x01, 0x1F},
{0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E},
{0x0E, 0x01, 0x01, 0x0F, 0x11, 0x11, 0x0E}};
void main()
{
unsigned char i;
unsigned char cnt;
unsigned char j;
while(1)
{
for(cnt=0;cnt<10;cnt++)
{
for(j=0;j<142;j++)
{
for(i=0;i<7;i++)
{
P0 = Font5x7[cnt][i];
P3 = 0x01<<i;
Delay_ms(1);
P3 = 0x00;
}
}
}
}
}
- Link download project. Click here
- Đây là ảnh mô phỏng protues.
- Đây là code chương trình.
#include"main.h"
#include"..\lib\delay.h"
unsigned char code Font5x7[10][7]={{0x0E,0x11,0x13,0x15,0x19,0x11,0x0E}, // Font cua so 0
{0x1F, 0x04, 0x04, 0x04, 0x14, 0x0C, 0x04}, // Font cua so 1
{0x1F, 0x08, 0x04, 0x02, 0x01, 0x11, 0x0E},
{0x0E, 0x11, 0x01, 0x06, 0x01, 0x11, 0x0E},
{0x02, 0x1F, 0x12, 0x08, 0x04, 0x02, 0x01},
{0x1E, 0x01, 0x01, 0x01, 0x1E, 0x10, 0x1F},
{0x0E, 0x11, 0x11, 0x1E, 0x10, 0x11, 0x0E},
{0x04, 0x04, 0x04, 0x02, 0x01, 0x01, 0x1F},
{0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E},
{0x0E, 0x01, 0x01, 0x0F, 0x11, 0x11, 0x0E}};
void main()
{
unsigned char i;
unsigned char cnt;
unsigned char j;
while(1)
{
for(cnt=0;cnt<10;cnt++)
{
for(j=0;j<142;j++)
{
for(i=0;i<7;i++)
{
P0 = Font5x7[cnt][i];
P3 = 0x01<<i;
Delay_ms(1);
P3 = 0x00;
}
}
}
}
}
- Link download project. Click here
EmoticonEmoticon