当前位置:网站首页>Construction of running water lamp experiment with simulation software proteus
Construction of running water lamp experiment with simulation software proteus
2022-06-12 07:10:00 【luffy5459】
In fact, the water lamp in the development of single chip microcomputer uses the principle of diode light , Build a row of diodes , Turn on one diode in turn , In the middle, delay is used to achieve a transitional effect , cycle , This is the effect of running water lamp we see .
Simulation software Proteus Build hardware projects in , choice 8051 Single chip microcomputer type , Finally, draw the circuit diagram as shown below :

In the source code file main.c Write the following code in :
#include <reg51.h>
#include <stdio.h>
unsigned char leddata[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void delay()
{
unsigned int i,j;
for(i=1000;i>0;i--)
{
for(j=110;j>0;j--);
}
}
void main(void)
{
unsigned int i;
for(i=0;i<8;i++)
{
P3 = leddata[i];
delay();
}
}compile , structure . Finally, the simulation is carried out , The effect is as follows :

The diode here is connected to P3 Pin 8 One pin , Here, the negative pole of the diode is uniformly grounded , To make them glow in turn , here P3 a row;Row 1 8 Pins must be input with high level in turn . When a pin is high , All other pins are low level . Therefore, each cycle is combined with delay lighting LED When , Need to give P3 assignment , here 8 The relationship between the lighting of the pins in turn is as follows :
0000 0001 -> 0x01
0000 0010 -> 0x02
0000 0100 -> 0x04
0000 1000 -> 0x08
0001 0000 -> 0x10
0010 0000 -> 0x20
0100 0000 -> 0x40
1000 0000 -> 0x80So in the code, we declare an array as follows :
unsigned char leddata[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};Give... In turn P3 Pin assignment , You can light up a diode .
This implementation uses arrays , In fact, every value of the array , All are 2 The power of , Based on this feature , You can also use a shift to give P3 Pin assignment , It's moving left 1<<1,1<<2,1<<3,1<<4,1<<5,1<<6,1<<7,1<<8, No more details here .
Here's what's interesting , If the common end of the diode is connected to the power supply , Here, the design drawing needs to modify the direction of the diode , And the code needs to be modified , Every time you need to light up LED Low level , So here's right P3 Assignment needs to be negated :
P3 = ~leddata[i]proteus Design and code the water flow lamp , Let us once again feel the joy of SCM programming . Mainly used Proteus Simulation software design circuit , Check electrical rules , code , Simulation , A series of operations , Finally, I was really excited to see the results of the experiment , Very excited , This is so much fun .
边栏推荐
- 初中学历,从不到3K,到月薪30K+,不设限的人生有多精彩
- 8 IO Library
- 丢掉丑陋的 toast,会动的 toast 更有趣
- [data clustering] data set, visualization and precautions are involved in this column
- PowerDesigner connects to entity database to generate physical model in reverse
- Planning and design of 1000 person medium-sized campus / enterprise network based on ENSP and firewall (with all configuration commands)
- Idea common shortcut keys
- [image denoising] image denoising based on partial differential equation (PDE) with matlab code
- Vscode outline preview cannot find file symbol
- Scons编译IMGUI
猜你喜欢

leetcode.39 --- 组合总和

Esp8266 firmware upgrade method (esp8266-01s module)

Day 4 of pyhon

Junior high school education, less than 3k, to 30k+ monthly salary, how wonderful life is without restrictions

Elegantly spliced XML

Recommend 17 "wheels" to improve development efficiency

TypeScript基础知识全集

Pyhon的第四天

9 Sequence container

RT thread studio learning (VIII) connecting Alibaba cloud IOT with esp8266
随机推荐
Tomato learning notes -vscade configuring makefile (using task.jason and launch.jason)
【WAX链游】发布一个免费开源的Alien Worlds【外星世界】脚本TLM
【数据聚类】本专栏中涉及数据集、可视化及注意事项
Troubleshooting of cl210openstack operation -- Chapter experiment
Drawing grid navigation by opencv map reading
应届生苦恼:是去华为拿1万多低薪,还是去互联网拿2万多高薪
Scons编译IMGUI
d不能用非常ctfe指针
Detailed explanation of TF2 command line debugging tool in ROS (parsing + code example + execution logic)
C language pointer
2 variables and basic types
Detailed explanation of 14 registers in 8086CPU
Expansion of D @nogc
sql server2019安装到这步无法进行下一步了,如何解决?
Detailed explanation of multi coordinate transformation in ROS (example + code)
Esp8266 firmware upgrade method (esp8266-01s module)
Lambda function perfect use guide
库里扛起了勇士对凯尔特人的第四场
Elegantly spliced XML
Flink practice