led花样灯问题 求大神 急急急

2019-07-15 12:11发布

                 #include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code Pattern_P0[]=
{
0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,
0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,
0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,
};
uchar code Pattern_P2[]=
{
0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,
0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,
0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,
};
//延时
void DelayMS(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
//主程序
void main()
{
uchar i=0,j=0,T=0;
while(1)
{//从数组中读取数据送至 P0 和 P2 口显示
for(i=0;i<136;i++)
{
P0=Pattern_P0[i];
P2=Pattern_P2[i];
DelayMS(100);
}
}
}


       课程设计 怎样在里面加两个按键 变成可调的两个模式,一个自动循环花样灯,一个可以控制花样。求大神,急啊

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
11条回答
ST_Lover
1楼-- · 2019-07-16 04:37
 精彩回答 2  元偷偷看……
ST_Lover
2楼-- · 2019-07-16 08:55
S1054459635 发表于 2017-1-2 16:35
能不能帮忙发个程序过来,当初没学好现在做课设学的好难啊

可以交流  1002925094                           
S1054459635
3楼-- · 2019-07-16 10:10
求大神帮忙啊  真的不行了
化心
4楼-- · 2019-07-16 13:34
你总两个判断语句试试,把要显示的放在判断语句里面,如果成立就执行不成立继续在主函数循环
iysheng
5楼-- · 2019-07-16 18:41
程序开头加上
sbit KEY=P1^0;
uchar key_flag=0x00;
修改main如下:
void main()
{
uchar i=0,j=0,T=0;
while(1)
{//从数组中读取数据送至 P0 和 P2 口显示
/*
*添加代码,判断按键是否按下,记得消抖
*/
    key_flag =!key_flag;//如果有按键按下,标志位取反
if(key_flag == 0x00)
for(i=0;i<136;i++)
{
P0=Pattern_P0;
P2=Pattern_P2;
DelayMS(100);
}//花样流水灯
}
}

一周热门 更多>