下载后可任意编辑/*----------------------------------------------- 名称:红绿灯 论坛:www
doflye
net 编写:shifang 日期:2024
5 修改:无 内容:1、程序目的:使用定时器学习 倒计时 红绿灯原理 主要程序与倒计时相同 2、硬件要求:数码管、晶振 12M3、P1 口连接至 LED 用于显示红绿灯4、数码管用于显示时间------------------------------------------------*/#include//包含头文件,一般情况不需要改动,//头文件包含特别功能寄存器的定义sbit LACTCH1=P2^2; sbit LACTCH2=P2^3;/*------------------------------------------------ 全局变量------------------------------------------------*/bit red,green,yellow,turnred;//定义红绿黄灯标志位code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //共阴数码管 0-9 unsigned char Dis_Shiwei;//定义十位unsigned char Dis_Gewei; //定义个位/*------------------------------------------------ ------------------------------------------------*/void delay(unsigned int cnt){ while(--cnt);}/*-----------------------------