历史上的今天
今天是:2025年04月14日(星期一)
2020年04月14日 | 单片机中实现8个LED的流水灯效果
2020-04-14 来源:eefocus
左移函数_crol_(x,y)和数组实现
#include #include #define uint unsigned int #define uchar unsigned char uchar temp;/*变量类型和赋的值最好一致,P1口为8位寄存器,选用uchar*/ void delay(uint); void main() { temp=0XFE; P1=temp; while(1) { temp=_crol_(temp,1); //循环左移 delay(300); P1=temp; } } void delay(uint z) { uint x,y; for(x=100;x>0;x--) for(y=z;y>0;y--); } ``` // 数组实现 ``` #include #include #define uint unsigned int #define uchar unsigned char uchar i; uchar table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; void delay(uint z) { uint x,y; for(x=100;x>0;x--) for(y=z;y>0;y--); } void main() { while(1) { for(i=0;i<8;i++) { P1=table[i]; delay(300); } } }
上一篇:51单片机静态数码管显示
史海拾趣
|
各位 高手,在下 寻找有关TSC 7107cpl / 8729BK 资料。用于连接着3位显示数码管的驱动 找到了 英文资料。。。 http://www.alldatasheet.com/view.jsp?Searchword=7107CPL http://www.alldatasheet.com/datash ...… 查看全部问答> |
|
矢野经济研究所预测2008年度消费类加速度传感器市场将比上年增长30.8%,达到2亿7450万个。车载用加速度传感器将比上年增长12.2%,达到 2亿8230万个。这样,消费类加速度传感器和车载用加速度传感器的个数将接近同等规模。另一方面,预计角速度传感 ...… 查看全部问答> |
|
泰为公司(www.telenav.com)招聘iPhone程序员 急聘 Please send your resume to lma@telenav.cn for internal referral. ----------------- We are recruiting C++ SE for iPhone team in urgent. If you have any referral, please forward the resume to me. Many thanks! Here is the adv ...… 查看全部问答> |
|
> 小弟刚接触Wince,装好了VS2005及其SP1,装好了Wince6.0,在VS2005中也出现了PB的插件. 照着网上的一些例子定制后,编译后提示如下: PB Debugger The Kernel Debugger is waiting to connect with target. 点击Targe-Attach Device后出现: ca ...… 查看全部问答> |
|
我是第一次使用MSP430这个MCU,在烧写程序方面发现有两种烧写器。一种是一端接JATG口,另一端接在PC机上的并口,这种好像很便宜。另外一种是通过一个仿真盒接在PC的USB口,这种好像贵些。 请问我只是想往MSP430里烧写代码,用第一种可以吗,第二种 ...… 查看全部问答> |
|
#define OUTMOD_0 (0*0x20u) /* PWM output mode: 0 - output only */ #define OUTMOD_1 (1*0x20u) /* PWM outpu ...… 查看全部问答> |




