程序下载:https://share.weiyun.com/JnNbxJUa
#include <reg52.h> //调用单片机头文件#define uchar unsigned char //宏定义"uchar"代替"unsigned char"。#define u8 unsigned char //宏定义"uchar"代替"unsigned char"。#define uint unsigned int //宏定义"uint"用来定义无符号整型数。//上下南北主干道//左右东西辅干道u8 code DisplayOther[]={0xff, //0 空0x7f, //1 "."0xbf, //2 "-"0xa7 //3 c};//数码管段选定义 0 1 2 3 4 5 6 7 8 9 A b C d E F -uchar code smg_du[17] = {0xc0, //00xf9, //10xa4, //20xb0, //30x99, //40x92, //50x82, //60xf8, //70x80, //80x90, //90x88, //A0x83, //b0xc6, //C0xa1, //d0x86, //E0x8e //F}; uchar dis_smg[8 ] = {0xc0,0xf5,0x8c,0x94,0xb1,0x92,0x82,0xf4}; uchar smg_i = 4; //显示数码管的个位数//数码管位选定义sbit smg_we1 = P2^0; //东西数码管2sbit smg_we2 = P2^1; //东西数码管1sbit smg_we3 = P2^3; //南北数码管2sbit smg_we4 = P2^2; //南北数码管1char dx_s = 0; //东西 南北 倒计时变量sbit nb_red = P1^0; //南北红灯sbit nb_green = P1^2; //南北绿灯sbit nb_yellow = P1^1; //南北黄灯 1sbit dx_red = P1^3; //东西红灯sbit dx_green = P1^5; //东西绿灯1sbit dx_yellow = |