LED流水灯
单片机源程序如下:
- /**********************************************************************
- ----------------1.开发环境:Keil v4 ----------------
- ----------------2.使用单片机型号:STC11F60XE ----------------
- ----------------3.单片机使用晶振:11.0592M或12M ----------------
- ----------------4.单片机教学用例 ----------------
- ----------------5.控制教研室 ----------------
- ***********************************************************************/
- #include "CONFIGURE.H"
- unsigned char tab[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
- unsigned char temp = 0xfe;
- //主函数
- void main()
- {
- unsigned char i;
- while(1)
- {
- //流水灯编写格式1
- LED1 = 0;
- Delay_ms(1000); //延时1s
- LED1 = 1;
- LED2 = 0;
- Delay_ms(1000); //延时1s
- LED2 = 1;
- LED3 = 0;
- Delay_ms(1000); //延时1s
- LED3 = 1;
- LED4 = 0;
- Delay_ms(1000); //延时1s
- LED4 = 1;
- LED5 = 0;
- Delay_ms(1000); //延时1s
- LED5 = 1;
- LED6 = 0;
- Delay_ms(1000); //延时1s
- LED6 = 1;
- LED7 = 0;
- Delay_ms(1000); //延时1s
- LED7 = 1;
- LED8 = 0;
- Delay_ms(1000); //延时1s
- LED8 = 1;
- P2 = 0XFF;
- Delay_ms(1000); //延时1s
-
- //流水灯格式2
- LED_BUS = 0XFE;
- Delay_ms(1000);
- LED_BUS = 0XFD;
- Delay_ms(1000);
- LED_BUS = 0XFB;
- Delay_ms(1000);
- LED_BUS = 0XF7;
- Delay_ms(1000);
- LED_BUS = 0XEF;
- Delay_ms(1000);
- LED_BUS = 0XDF;
- Delay_ms(1000);
- LED_BUS = 0XBF;
- Delay_ms(1000);
- LED_BUS = 0X7F;
- Delay_ms(1000);
- //流水灯格式3
- for(i = 0 ; i < 8 ;i++)
- {
- P2 = tab[i];
- Delay_ms(1000);
- }
- //流水灯的格式4
- LED_BUS = temp;
- Delay_ms(1000);
- temp = (temp << 1) | 0x01;
- if(temp == 0xff)
- {
- temp = 0xfe;
- }
- }
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
02.LED流水灯.zip
(8.4 KB, 下载次数: 26)
|