STC89C52RC 单片机 多种花样的流水灯 有外部中断0节一按键,每按一次切换一次流水灯花样。可以用来做超级炫酷的自行车电动车尾灯,炫酷爆闪灯。 分类: 自拍 标签: 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); } } } 0:00) 大烟山(Smoky Mountains)的秋天(2013-11-21 21:13:00) 3D打印是个天大的谎言 不可能颠覆制造业(2013-11-21 20:34:00) 理者的魅力源泉(2013-11-21 20:31:00) 不要在你无可救药地老去时抱怨“精力有限”(2013-11-21 20:29:00) 彩色灯光控制系统(2013-11-10 23:04:00) 51单片机18B20 测温,可怕的85度(2013-11-10 0:25:00) 51单片机使用18B20温度采集c51源程序(2013-11-10 0:23:00) 最近浏览的电子制作方面单片机的文章(2013-11-6 8:02:00)

评论