您的位置 首页 FPGA

8×8 LED 矩阵显现

C代码:#includereg51.h>unsignedcharcodetaba[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};unsignedchar

C代码:

#include
unsigned char code taba[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code tabb[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void delay(void)
{
unsigned char i,j;
for(i=10;i>0;i–)
for(j=248;j>0;j–);
}
void delay1(void)
{
unsigned char i,j,k;
for(k=10;k>0;k–)
for(i=20;i>0;i–)
for(j=248;j>0;j–);
}
void main(void)
{
unsigned char i,j;
while(1)
{
for(j=0;j<3;j++) //from left to right 3 time
{
for(i=0;i<8;i++)
{
P0=taba[i];
P3=0xff;
delay1();
}

}
for(j=0;j<3;j++) //from right to left 3 time
{
for(i=0;i<8;i++)
{
P0=taba[7-i];
P3=0xff;
delay1();
}
}
for(j=0;j<3;j++) //from top to bottom 3 time
{
for(i=0;i<8;i++)
{
P0=0x00;
P3=tabb[7-i];
delay1();
}
}
for(j=0;j<3;j++) //from bottom to top 3 time
{
for(i=0;i<8;i++)
{ P0=0x00;
P3=tabb[i];
delay1();
}
}
}
}
仿真原理图:

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/fpga/268430.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部