当前位置:网站首页>[51 single chip microcomputer traffic light simulation]
[51 single chip microcomputer traffic light simulation]
2022-04-23 13:02:00 【ZLP~】
Traffic light design and simulation
Topic quantity : 1 Full marks : 100 branch The creator : Wang Jianing By the time :2022-04-24 11:54
One . Short answer ( common 1 topic ,100.0 branch )
1
See the example of traffic lights in Chapter 6 of the book , Design and simulate , Count down the original program 20 Seconds to countdown 15 second . requirement Proteus Draw the circuit diagram to reflect the student number and name , And record the simulation effect .
Fill in the answer
#include "reg51.h"
sbit in1 = P2^1;
sbit in2 = P2^2;
sbit in3 = P2^3;
sbit in4 = P2^4;
sbit in5 = P2^5;
sbit in6 = P2^6;
typedef unsigned char u8;
u8 a[]={
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void delay(int ms)
{
int i,j;
for(i=ms;i>0;i--)
for(j=110;j>0;j--);
}
void display(int d)
{
int f = d;
while(f>=0)
{
if(f<10)
{
P3=a[f];
P1=a[0];
f=f-1;
delay(1000);
}
if(f>=10)
{
P3=a[f%10];
P1=a[f/10];
f=f-1;
delay(1000);
}
}
}
void one()
{
in1=0;
in2=1;
in3=0;
in4=1;
in5=0;
in6=0;
}
void two()
{
in1=0;
in2=1;
delay(800);
in2=0;
delay(800);
in3=0;
in4=1;
in5=0;
in6=0;
}
void three()
{
in1=0;
in2=0;
in3=1;
in4=1;
in5=0;
in6=0;
}
void four()
{
in1=1;
in2=0;
in3=0;
in4=0;
in5=1;
in6=0;
}
void five()
{
in1=1;
in2=0;
in3=0;
in4=0;
in5=1;
delay(800);
in5=0;
delay(800);
in6=0;
}
void six()
{
in1=1;
in2=0;
in3=0;
in4=0;
in6=1;
delay(800);
in6=0;
delay(800);
in5=0;
}
int main()
{
int i=0;
in1=0;
in2=0;
in3=0;
in4=0;
in5=0;
in6=0;
while(1)
{
one();
display(20);
two();
display(3);
three();
display(2);
four();
display(20);
five();
display(3);
six();
display(2);
}
}
traffic lights - Proteus 8 Mapping
Hand in your homework and remember the function name
版权声明
本文为[ZLP~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230613177201.html
边栏推荐
- 22. 括号生成
- decast id.var measure. Var data splitting and merging
- 将新增和编辑的数据同步更新到列表
- 软件测试周刊(第68期):解决棘手问题的最上乘方法是:静观其变,顺水推舟。
- 云原生KubeSphere部署Redis
- Design and manufacture of 51 single chip microcomputer solar charging treasure with low voltage alarm (complete code data)
- Process virtual address space partition
- Record some NPM related problems (messy records)
- 31. 下一个排列
- Remote access to raspberry pie at home (Part 1)
猜你喜欢
R语言中dcast 和 melt的使用 简单易懂
Packet capturing and sorting -- TCP protocol [8]
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
[vulnhub range] - DC2
STM32 control stepper motor (ULN2003 + 28byj)
Install nngraph
5 free audio material websites, recommended collection
SSM框架系列——注解开发day2-2
three.js文字模糊问题
随机推荐
Synchronously update the newly added and edited data to the list
The accuracy and speed are perfectly balanced, and the latest image segmentation SOTA model is released!!!
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
HQL find the maximum value in a range
Use source insight to view and edit source code
SSM framework series - annotation development day2-2
云原生KubeSphere部署Redis
Important knowledge of transport layer (interview, retest, final)
There is no need to crack the markdown editing tool typora
5 free audio material websites, recommended collection
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
Start mqbroker CMD failure resolution
JMeter operation redis
Common problems of unity (1)
数据库中的日期时间类型
The continuous construction of the Internet industry platform is not only able to collect traffic
At instruction of nbiot
async void 導致程序崩潰
Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow
Recovering data with MySQL binlog