当前位置:网站首页>Introduction to single chip microcomputer: LED lights cycle to the left and turn on
Introduction to single chip microcomputer: LED lights cycle to the left and turn on
2022-07-24 15:28:00 【Electronic engineer Growth Diary】
To study the LED After the light is on and flashing , Now try to move left LED The cycle of the lamp is on .
Hardware circuit design
combination 51 Knowledge of the smallest system of single chip microcomputer , utilize AD19 Draw the minimum system circuit ( Power supply part is not included ).
This design needs to realize 8 individual LED The cycle of the lamp is on .LED( Light-emitting diode ) Positive connection +5V Power Supply , The negative pole is connected to the single chip microcomputer P1 mouth , In this way, as long as the SCM P1 The diode can be turned on when the output level of the port is high or low , Realization LED Light on and off .
Simulation circuit design
Simulation circuit diagram and AD The schematic drawing method is consistent , However, it should be noted that the capacitance value in the simulated minimum system reset circuit is 0.1uf, Resistance value 100Ω, And AD There are differences in the schematic diagram .
Programming
The program uses Keil5 Design ,8 position LED Program moved left :
/*-----------------------------------------------
name :IO Port high and low level control
Content : Cycle left to light up one LED The lamp , Shift left symbol <<
------------------------------------------------*/
#include<reg52.h> // Include header file , In general, there is no need to change , The header file contains the definition of special function registers
#include<intrins.h> // Because you're going to use the left-right shift function , So add this header file
#define led P1 // take P1 The mouth is defined as led You can use it later led Instead of P1 mouth
void Delay(unsigned int t); // Function declaration
/*------------------------------------------------
The main function
------------------------------------------------*/
void main (void)
{
unsigned char i; // Define an unsigned character local variable i Value range 0~255
led=~0x01;
Delay(50000); // About time delay 450ms
while(1)
{
for(i=0;i<8;i++)
{
P1=~(0x01<<i); // Move left i position , Then assign the result to P1 mouth
Delay(50000); // About time delay 450ms
}
}
}
/*------------------------------------------------
The time delay function , Contains input parameters unsigned int t, No return value
unsigned int Is to define unsigned integer variables , The range of values is
0~65535
------------------------------------------------*/
void Delay(unsigned int t)
{
while(t--);
}Simulation Implementation
In order to intuitively feel the effect of this design , Here use protues8.7 Simulation Implementation LED Of a lamp LED The lamp moves left and turns on , See the video for details .
http://mpvideo.qpic.cn/0bf2yeaaiaaaveae7os6gnpvbqodataqabaa.f10002.mp4?
边栏推荐
- MATLAB image defogging technology GUI interface - global balance histogram
- Performance test - Preparation of test plan
- [300 opencv routines] 238. Harris corner detection in opencv
- Sword finger offer II 001. integer division
- 4279. 笛卡尔树
- 接参处理和@Param
- [tkinter beautification] window out of system style (common to three systems)
- 你不能只会flex居中布局,精制动画讲解所有flex布局方式!通俗易懂纯干货教程!...
- 27.目录与文件系统
- 图的存储和遍历
猜你喜欢

kubernetes多网卡方案之Multus_CNI部署和基本使用

【着色器实现Pixelate马赛克效果_Shader效果第七篇】
![Error reporting [project error reporting]](/img/7a/322ba86c13667a62c484b2329ac617.png)
Error reporting [project error reporting]

Jmeter-调用上传文件或图片接口

26. Code implementation of file using disk

【机器学习基础】——另一个视角解释SVM
![[quantitative test]](/img/df/f2d8b252169213af340f3e535bddef.png)
[quantitative test]

Summary of feature selection: filtered, wrapped, embedded

【Bug解决】Win10安装pycocotools报错

2022 RoboCom 世界机器人开发者大赛-本科组(省赛)-- 第二题 智能服药助手 (已完结)
随机推荐
什么是防火墙?防火墙能发挥什么样的作用?
Kubectl_好用的命令行工具:oh-my-zsh_技巧和窍门
Outlook tutorial, how to set rules in outlook?
在哪家证券公司开户最好最安全 如何开户炒股票
Property datasource is required exception handling [idea]
15. Talk about these common multi-threaded interview questions
2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 2: intelligent medication assistant (finished)
Various searches (⊙▽⊙) consolidate the chapter of promotion
Istio1.12:安装和快速入门
【Flutter -- 布局】流式布局(Flow和Wrap)
Sklearn.metrics module model evaluation function
25.从生磁盘到文件
Calculate the M-day moving average price of two stocks
Circular structure practice
MySQL build master-slave synchronization - build with docker
Detailed explanation of document operation
Jmeter-调用上传文件或图片接口
What is a firewall? What role can firewalls play?
MySql函数
[machine learning basics] - another perspective to explain SVM