本帖最后由 ZHANGJINGYU 于 2016-12-23 01:13 编辑
今天开始,哦不,应该是昨天开始学习51,发现自己停不下来了!本来在12点打算睡觉的,却没忍住,拿起教材又看了看,这次是流水灯,教材上只列举了单向的流水灯程序,但我看过很多大神的流水灯都是双向来回跑的!于是自己仔细分析,慢慢琢磨,终于搞出来了!come on!筒子们,我要免费贴代码了!
代码:
- #include <reg52.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define LED P1
- void delay( timer )
- {
- uint i,j;
- for (i = timer; i > 0; i --)
- for (j = 125; j > 0; j --);
- }
- void main ()
- {
- uint count;
- count = 0;
- while (1)
- {
- //LED = 0X01; //0000 0001
- LED = ~(0x01 << count);
- count ++;
- delay(100);
- if (count == 8)
- {
- while(count --)
- {
- LED = ~(0x01 << count);
- delay(100);
- }
- }
- }
- }
晚安!
有点兴奋!用流量开热点!发帖子!!!!