正文

STC89C52RC 单片机 多种花样的流水灯2013-12-06 09:11:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/enc999/54358.html

分享到:

STC89C52RC 单片机 多种花样的流水灯
有外部中断0节一按键,每按一次切换一次流水灯花样。可以用来做超级炫酷的自行车电动车尾灯,炫酷爆闪灯。
分类:
自拍


C51 源程序 如下:

#include <reg52.h>
#define LED_PORT P0
sbit KEY=P3^2;
unsigned char Mod_LED;
unsigned char code Tab_LED[][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff},
{0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80},
{0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01},
{0x03,0x06,0x0c,0x18,0x30,0x60,0xc0,0x81},
{0x81,0xc0,0x60,0x30,0x18,0x0c,0x06,0x03},
{0x18,0x3c,0x7e,0xff,0x7e,0x3c,0x18,0x00},
{0x18,0x24,0x42,0x81,0x81,0x42,0x24,0x18},
{0x10,0x00,0x28,0x00,0x44,0x00,0x82,0x00},
{0x55,0x00,0xaa,0x00,0x55,0x00,0xaa,0x00},
{0x3c,0x00,0x00,0xc3,0x00,0x3c,0x00,0xc3}};
void delayms(unsigned char ms)
{
unsigned char i;
while(ms--)
for(i=0;i<120;i++)
}
void int0_int(void) interrupt 0 using 0
{
delayms(10);
if(!KEY)
{
Mod_LED++;
Mod_LED%=11;

while(!KEY) ;
}
void main()
{
unsigned char i;
EA=1; //INT0 中断初始化
EX0=1;
EX1=1;
while(1)
{
for(i=0;i<8;i++)
{
LED_PORT=~Tab_LED[Mod_LED][i];
delayms(150);
}
}
}

阅读(2088) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册