当前位置:网站首页>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?
边栏推荐
- 2022 robocom world robot developer competition - undergraduate group (provincial competition) -- fifth question tree and bipartite diagram (completed)
- 2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 3 running team robot (finished)
- DS inner row heap sort
- 25. From disk to file
- 请问好的券商的排名?网上开户安全吗
- 在哪家证券公司开户最好最安全 如何开户炒股票
- Exomeiser annotates and prioritizes exome variants
- Activity Registration: how to quickly start the open source tapdata live data platform on a zero basis?
- DS binary tree - maximum distance of binary tree nodes
- 【Flutter -- 布局】流式布局(Flow和Wrap)
猜你喜欢

25. From disk to file

2022 RoboCom 世界机器人开发者大赛-本科组(省赛)RC-u4 攻略分队 (已完结)

Reentrantlock reentrant lock

Cloud development standalone image Jiugongge traffic main source code

27.目录与文件系统

2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 3 running team robot (finished)

AG. DS binary tree -- hierarchical traversal

25.从生磁盘到文件

Unity uses NVIDIA flex for unity plug-in to realize the effects of making software, water, fluid, cloth, etc. learning tutorial

Intuitive understanding of various normalization
随机推荐
MySQL function
Summary of feature selection: filtered, wrapped, embedded
各种Normalization的直观理解
Performance test - analyze requirements
三、集合基础——ArrayList集合与简单学生管理系统
VAE(变分自编码器)的一些难点分析
PyTorch的自动求导
4279. Cartesian tree
2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 2: intelligent medication assistant (finished)
力扣 31.下一个排列--双指针法
C# SQLite Database Locked exception
[machine learning basics] - another perspective to explain SVM
2022 RoboCom 世界机器人开发者大赛-本科组(省赛)RC-u4 攻略分队 (已完结)
2022 RoboCom 世界机器人开发者大赛-本科组(省赛) CAIP 完整版题解
Performance test - Preparation of test plan
4279. 笛卡尔树
Leetcode 1288. delete the covered interval (yes, solved)
[quantitative test]
C# SQLite Database Locked exception
pytorch with torch.no_ grad