当前位置:网站首页>[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
边栏推荐
- Byte warehouse intern interview SQL questions
- 如何实现点击一下物体播放一次动画
- V-model binding value in El select, data echo only displays value, not label
- mysql8安装
- three.js文字模糊问题
- Date time type in database
- Introducing vant components on demand
- Customize the shortcut options in El date picker, and dynamically set the disabled date
- World Book Day: I'd like to recommend these books
- Connect orcale
猜你喜欢

Free and open source agricultural Internet of things cloud platform (version: 3.0.1)

Deploying MySQL in cloud native kubesphere

Important knowledge of transport layer (interview, retest, final)

SSM框架系列——数据源配置day2-1

The quill editor image zooms, multiple rich text boxes are used on one page, and the quill editor upload image address is the server address

Pytorch: a pit about the implementation of gradreverselayer

SSM框架系列——注解开发day2-2

Servlet监听器&过滤器介绍

世界读书日:我想推荐这几本书

云原生KubeSphere部署Mysql
随机推荐
The continuous construction of the Internet industry platform is not only able to collect traffic
(1) Openjuterpyrab comparison scheme
Record a website for querying compatibility, string Replaceall() compatibility error
Translation of multi modal visual tracking: review and empirical comparison
HQL statement tuning
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
云原生KubeSphere部署Redis
31. 下一个排列
Golang implements MD5, sha256 and bcrypt encryption
进程虚拟地址空间区域划分
three.js文字模糊问题
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
Go language array operation
V-model binding value in El select, data echo only displays value, not label
8 websites that should be known for product development to enhance work experience
Sort out several uses of network IP agent
[csnote] ER diagram
[vulnhub range] - DC2
Translation of attention in natural language processing
Temperature and humidity monitoring + timing alarm system based on 51 single chip microcomputer (C51 source code)