当前位置:网站首页>Introduction to single chip microcomputer: LED bidirectional water lamp
Introduction to single chip microcomputer: LED bidirectional water lamp
2022-07-24 15:29:00 【Electronic engineer Growth Diary】
To study the LED After the lamp moves left and right , The following implementation LED The two-way movement of the lamp turns 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 Move the lighted program left and right :
/*-----------------------------------------------
name :IO Port high and low level control
Content : First move right to light LED The lamp , Move left again and turn on , Realization LED Two way movement
------------------------------------------------*/
#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
unsigned char j; // Define an unsigned character local variable j Value range 0~255
led=~0x80;
Delay(50000); // About time delay 450ms
while(1)
{
for(i=0;i<8;i++)
{
P1=~(0x80>>i); // Move right i position , Then assign the result to P1 mouth
Delay(50000); // About time delay 450ms
}
for(j=0;j<8;j++)
{
P1=~(0x01<<j); // Move right j 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 The lamp moves in both directions and turns on , See the video for details .
http://mpvideo.qpic.cn/0b78emaaeaaaxeafdnc6gvpvai6dairqaaqa.f10002.mp4?
边栏推荐
- Intuitive understanding of various normalization
- [fluent -- layout] flow layout (flow and wrap)
- C - partial keyword
- C. Recover an RBS
- [tkinter beautification] window out of system style (common to three systems)
- 在哪家证券公司开户最好最安全 如何开户炒股票
- Citic securities account opening process, is it safe to open an account on your mobile phone
- [machine learning basics] - another perspective to explain SVM
- Huawei camera capability
- Overall testing framework for performance testing
猜你喜欢

Android section 13 detailed explanation of 03sqlite database

2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 1: don't waste gold (finished)

2022 RoboCom 世界机器人开发者大赛-本科组(省赛)-- 第三题 跑团机器人 (已完结)

【Bug解决】Win10安装pycocotools报错

Choice of advanced anti DDoS IP and CDN in case of DDoS

【OpenCV 例程300篇】238. OpenCV 中的 Harris 角点检测

你不能只会flex居中布局,精制动画讲解所有flex布局方式!通俗易懂纯干货教程!...

25.从生磁盘到文件

Overall testing framework for performance testing

VAE(变分自编码器)的一些难点分析
随机推荐
Choice of advanced anti DDoS IP and CDN in case of DDoS
JSON file editor
PyTorch的自动求导
C# 无操作则退出登陆
Outlook tutorial, how to create tasks and to DOS in outlook?
维护香港服务器安全的9个关键措施
Existence form and legitimacy of real data in C language (floating point number)
[TA frost wolf \u may - hundred people plan] Figure 3.4 introduction to delayed rendering pipeline
Applet tab
Reentrantlock reentrant lock
MySQL function
What is a firewall? What role can firewalls play?
【Flutter -- 布局】流式布局(Flow和Wrap)
Discussion and legitimacy of the order of entering and leaving the stack
2022 robocom world robot developer competition - undergraduate group (provincial competition) CAIP full version solution
你不能只会flex居中布局,精制动画讲解所有flex布局方式!通俗易懂纯干货教程!...
You can't just focus on flex layout and elaborate animation to explain all flex layout methods! Easy to understand dry goods tutorial
Preparation of mobile end test cases
Error reporting [project error reporting]
请问好的券商的排名?网上开户安全吗