单片机程序源代码.pdf
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
在这些任务中,我们主要关注的是使用89C51单片机进行LED灯的控制。89C51是一款常见的微控制器,广泛应用于嵌入式系统,具有8KB的可编程只读存储器(EPROM)和4KB的RAM。在这些任务中,通过编写源代码,我们可以看到89C51如何控制LED灯实现不同的动态效果。 任务一介绍了如何设计一个简单的闪烁广告灯。这里使用了两个LED(D0和D1),通过P0口的两个位(sbit LED1=P0^0和sbit LED2=P0^1)来控制。程序的核心部分是`delayms()`函数,用于延迟一段时间,以及主函数`main()`,其中使用了一个无限循环来交替设置LED的状态,实现两个LED交替闪烁的效果。 任务二涉及到了流水广告灯的设计。8个LED(D0到D7)按照特定顺序依次点亮和熄灭,形成流水效果。这里使用了`_crol_()`函数来进行位左移操作,每次循环将P0口的值左移一位,达到LED逐个点亮的效果。同样,也包含了一个`delayms()`函数来控制每个状态的持续时间。 任务三展示了拉幕式和闭幕式广告灯的设计。在这个任务中,8个LED的亮灭按照特定顺序进行,从两端开始逐渐点亮或熄灭。通过数组`table[]`存储预设的LED状态,并使用`delay()`函数来控制延迟,然后通过`for`循环来依次设置P0口的值,实现拉幕和闭幕的效果。 任务四是最复杂的广告灯设计,包含了多种显示模式。LED灯的控制模式包括正向流水、反向流水、隔灯闪烁、高四盏低四盏闪烁以及隔两盏闪烁。这里使用了三个数组`xx[]`, `yy[]`, `zz[]`来存储特定的LED状态,并结合多个嵌套的`for`循环和`delayms()`函数来实现各种动态效果的切换和循环。 通过以上四个任务,我们可以学习到89C51单片机的基本I/O操作,如端口位的设置和清除,以及如何通过位操作函数来实现数据的位移。同时,理解了如何用延时函数来控制LED灯的闪烁速度,以及如何通过循环和条件判断来实现复杂的灯光效果。此外,还可以看到C语言在编写嵌入式程序中的应用,例如定义位变量、宏定义以及数组的使用。这些知识对于进行单片机开发和嵌入式系统设计是非常基础且重要的。
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/release/download_crawler_static/87955196/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/87955196/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/87955196/bg3.jpg)
![](https://csdnimg.cn/release/download_crawler_static/87955196/bg4.jpg)
![](https://csdnimg.cn/release/download_crawler_static/87955196/bg5.jpg)
剩余43页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 67
- 资源: 5万+
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)