基于单片机的智能交通灯控制系统设计 - 图文(8)

2019-08-29 00:42

XXXXXX毕业设计

} }

//夜间模式 void night() {

if(botton3 == 0) {

delay_ms(10);

if(botton3 == 0) //判断是否按下按键进入夜间模式 {

u8 flag = 1; while(!botton3); TR0 = 0;

//timebreak0 = 0; initcross(); while(flag) {

dx_yel = 0; nb_yel = 0; initnumber();

if(botton3 == 0) //第二次按下退出夜间模式 {

delay_ms(10); if(botton3 == 0) {

flag =0;

while(!botton3); } } }

initcross(); TR0 = 1;

breakflag = 1; } } }

//路口调时 第一次按下=》设置东西红灯的时间;第二次按下=》设置东西绿灯的时间;第三次按下=》确认并退出 void settime() {

if(botton4 == 0)

32

XXXXXX毕业设计

{

delay_ms(10);

if(botton4 == 0) {

while(!botton4); TR0 = 0;

count_settime = 0; //timebreak0 = 0; initcross();

count_settime ++; //记录按键次数 while(count_settime < 3) {

if(count_settime == 1) {

dx_red = 0; }

else if(count_settime == 2) {

dx_red = 1; dx_gre = 0; }

addtime(); //加时间 cuttime(); //减时间

if(count_settime == 1) 下设置东西红灯的时间 {

dx_redtime = dx_redtime + count_time; nb_redtime = dx_gretime + yeltime; nb_gretime = dx_redtime - yeltime; count_time = 0; }

else if(count_settime == 2) 下设置东西绿灯的时间 {

dx_gretime = dx_gretime + count_time; nb_redtime = dx_gretime + yeltime; nb_gretime = dx_redtime - yeltime; count_time = 0; }

if(botton4 == 0)

33

第一次按

第二次按

//

//XXXXXX毕业设计

{

delay_ms(10); if(botton4 == 0) {

while(!botton4); count_settime ++; } } }

count_time = 0; //清空时间改变量

count_settime = 0; //清空按键计数变量 initcross(); breakflag = 1;

TR0 = 1; //打开定时器 } } }

//时间加

void addtime() {

if(botton5 == 0) {

delay_ms(10); if(botton5 == 0) {

u8 flag = 1; while(!botton5); count_time ++; while(flag) {

switch (count_settime) 显示时间

{

case 1:display_2(DONG,count_time + dx_redtime); display_2(XI,count_time + dx_redtime); display_2(NAN,count_time + dx_redtime); display_2(BEI,count_time + dx_redtime); break;

case 2:display_2(DONG,count_time + dx_gretime); display_2(XI,count_time + dx_gretime); display_2(NAN,count_time + dx_gretime); display_2(BEI,count_time + dx_gretime);

34

//调节时

XXXXXX毕业设计

break;

default: initnumber(); }

if(botton5 == 0) {

delay_ms(10); if(botton5 == 0) {

count_time ++; while(!botton5); } }

if(botton4 == 0) {

delay_ms(10); if(botton4 == 0) {

flag = 0;

while(!botton4); } }

if(botton6 == 0) {

delay_ms(10); if(botton6 == 0) {

while(!botton6); flag = 0;

//count_time --; cuttime(); } } } } } }

//时间减

void cuttime() {

if(botton6 == 0) {

delay_ms(10);

35

//按下调时键退出时间加

//按下时间减键进入时间减

XXXXXX毕业设计

if(botton6 == 0) {

u8 flag = 1; while(!botton6); count_time --; while(flag) {

时显示时间

switch (count_settime) //调节{

case 1:display_2(DONG,count_time + dx_redtime); display_2(XI,count_time + dx_redtime); display_2(NAN,count_time + dx_redtime); display_2(BEI,count_time + dx_redtime); break;

case 2:display_2(DONG,count_time + dx_gretime); display_2(XI,count_time + dx_gretime); display_2(NAN,count_time + dx_gretime); display_2(BEI,count_time + dx_gretime); break;

default: initnumber(); }

if(botton6 == 0) {

delay_ms(10); if(botton6 == 0) {

count_time --; while(!botton6); } }

if(botton4 == 0) //按下调时键退出时间减 {

delay_ms(10); if(botton4 == 0) {

flag = 0;

while(!botton4); } }

if(botton5 == 0) //按下时间加键进入时间加 {

delay_ms(10);

36


基于单片机的智能交通灯控制系统设计 - 图文(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:液压与气动复习题及答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: