当前位置:网站首页>【51单片机交通灯仿真】
【51单片机交通灯仿真】
2022-04-23 06:13:00 【ZLP啊~】
交通灯设计与仿真
题量: 1 满分: 100 分 创建者:王佳宁 截止时间:2022-04-24 11:54
一.简答题(共1 题,100.0分)
1
查看书中第六章的交通灯实例,设计并进行仿真,将原程序中倒计时20秒改为倒计时15秒。要求Proteus绘制电路图中体现学号姓名,并录制仿真效果。
填写答案
#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);
}
}
交通灯 - Proteus 8 理图绘制
交作业记得该函数名
版权声明
本文为[ZLP啊~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52297353/article/details/124346930
边栏推荐
- 【点云系列】Relationship-based Point Cloud Completion
- Face_ Recognition face detection
- [dynamic programming] triangle minimum path sum
- [Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation
- ArcGIS license server administrator cannot start the workaround
- RISCV MMU 概述
- [point cloud series] a rotation invariant framework for deep point cloud analysis
- PyTorch 22. PyTorch常用代码段合集
- Pytorch模型保存与加载(示例)
- imx6ull-qemu 裸机教程1:GPIO,IOMUX,I2C
猜你喜欢
[Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation
使用 trt 的int8 量化和推断 onnx 模型
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
EasyUI combobox determines whether the input item exists in the drop-down list
Machine learning III: classification prediction based on logistic regression
ArcGIS License Server Administrator 无法启动解决方法
主流 RTOS 评估
ARMCC/GCC下的stack protector
Gephi教程【1】安装
Systrace 解析
随机推荐
PyTorch 13. 嵌套函数和闭包(狗头)
Pytoch model saving and loading (example)
第4章 Pytorch数据处理工具箱
Raspberry Pie: two color LED lamp experiment
使用 trt 的int8 量化和推断 onnx 模型
直观理解 torch.nn.Unfold
Data class of kotlin journey
【动态规划】不同路径2
Gephi教程【1】安装
Some common data type conversion methods in pytorch are similar to list and NP Conversion method of ndarray
FATFS FAT32学习小记
第2章 Pytorch基础2
Chapter 5 fundamentals of machine learning
机器学习 三: 基于逻辑回归的分类预测
Chapter 2 pytoch foundation 2
Five methods are used to obtain the parameters and calculation of torch network model
torch.where能否传递梯度
机器学习——朴素贝叶斯
【 planification dynamique】 différentes voies 2
MySQL的安装与配置——详细教程