#include<reg52.h>
typedef unsigned int u16;
typedef unsigned char u8;
#define smg P0
sbit duan1=P2^6;
sbit duan2=P2^7;
sbit east_r=P1^6;
sbit east_g=P1^7;
sbit east_y=P3^3;
sbit west_r=P1^0;
sbit west_g=P1^1;
sbit west_y=P1^2;
sbit south_r=P3^4;
sbit south_g=P3^5;
sbit south_y=P3^6;
sbit north_r=P1^3;
sbit north_g=P1^4;
sbit north_y=P1^5;
sbit key1=P2^2;
sbit key2=P2^3;
sbit key3=P2^4;
sbit key4=P2^5;
sbit beep=P2^0;
code xians[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
u16 i,s=0,a=20,b=30,w,count;
{ while(i--);}
void Timer0Inti(void)
{
TMOD|=0X01;
TH0=0X3c;
TL0=0Xb0;
ET0=1;
EA=1;
TR0=1;
}
void nb_g()
{
north_r=0;north_g=1;
south_r=0;south_g=1;
east_r=1;east_g=0;
west_r=1;east_g=0;
}
void dx_g()
{
north_r=1;north_g=0;
south_r=1;south_g=0;
east_r=0;east_g=1;
west_r=0;west_g=1;
}
void nb_y()
{
south_y=1;north_y=1;south_g=0;north_g=0;
delay(20000);
south_y=0;north_y=0;south_g=0;north_g=0;
delay(20000);
south_y=1;north_y=1;south_g=0;north_g=0;
delay(20000);
south_y=0;north_y=0;south_g=0;north_g=0;
delay(20000);
south_y=1;north_y=1;south_g=0;north_g=0;
delay(20000);
south_y=0;north_y=0;south_g=0;north_g=0;
delay(20000);
south_y=1;north_y=1;south_g=0;north_g=0;
delay(20000);
south_y=0;north_y=0;south_g=0;north_g=0;
delay(20000);
south_y=1;north_y=1;south_g=0;north_g=0;
delay(20000);
south_y=0;north_y=0;south_g=0;north_g=0;
delay(20000);
}
void dx_y()
{
east_y=1;west_y=1;east_g=0;west_g=0;
delay(20000);
east_y=0;west_y=0;east_g=0;west_g=0;
delay(20000);
east_y=1;west_y=1;east_g=0;west_g=0;
delay(20000);
east_y=0;west_y=0;east_g=0;west_g=0;
delay(20000);
east_y=1;west_y=1;east_g=0;west_g=0;
delay(20000);
east_y=0;west_y=0;east_g=0;west_g=0;
delay(20000);
east_y=1;west_y=1;east_g=0;west_g=0;
delay(20000);
east_y=0;west_y=0;east_g=0;west_g=0;
delay(20000);
east_y=1;west_y=1;east_g=0;west_g=0;
delay(20000);
east_y=0;west_y=0;east_g=0;west_g=0;
delay(20000);
}
void smg_xs()
duan1=1;
duan2=0;
smg=xians[count/10];
Delay5ms();
duan1=0;
duan2=1;
smg=xians[count%10];
}
void jinji()
{
east_r=1;east_g=1;east_y=1;
west_r=1;west_g=1;west_y=1;
south_r=1;south_g=1;south_y=1;
north_r=1;north_g=1;north_y=1;
}
void led_csh()
{
east_r=0;east_g=0;east_y=0;
west_r=0;west_g=0;west_y=0;
south_r=0;south_g=0;south_y=0;
north_r=0;north_g=0;north_y=0;
}
void key_scan()
{
if(key1==0)
{
delay(20);
if(key1==0)
{delay(50000);
EA=0;
s++;
w=s%4;
}
if(key4==0)
{
delay(10);
if(key4==0) { jinji();beep=0;delay(50000);beep=1;delay(50000);led_csh();key1=1; }
}
}
void main()
{
u16 y=0;
delay(10000);
led_csh();
TimerInti();
beep=1;
smg_xs();
while(1)
{ beep=0;
key_scan();
if(w==2)
if(key2==0) {delay(20000);a=a+1;if(a>60) a=30;}
if(key3==0) {delay(20000);a=a-1;if(a==0) a=30;}
duan1=1;
duan2=0;
smg=xians[a/10];
duan1=0;
duan2=1;
smg=xians[a%10];
a=a;
}
if(w==1)
{ if(key2==0) {delay(20000);b=b+1;if(b>60)b=30;}
if(key3==0) {delay(20000);b=b-1;if(b==0)b=30;}
duan1=1;
duan2=0;
smg=xians[b/10];
Delay5ms();
duan1=0;
duan2=1;
smg=xians[b%10];
Delay5ms();
b=b;
}
if(w==3)
{
jinji();beep=0;delay(500);beep=1;TR0=0;delay(50000);led_csh();TR0=1;key1=1;
}
if(w==0)
TR0=1;
if(y==0)
{
smg_xs();
dx_g();
if(count==0) {smg_xs();
delay(50000); dx_y();count=b;y=1;led_csh(); }
}
if(y==1)
{ smg_xs(); nb_g();
if(count==0) {smg_xs();delay(50000); nb_y();count=a;y=0;led_csh(); }
}
}
}
void Time0(void) interrupt 1
u16 s;
TH0=0X3c;
TL0=0xb0;
s++;
if(s==20)
{ count--;if(count==0)delay(50000); s=0;}
}
白茶丫
- 粉丝: 4w+
- 资源: 1859
最新资源
- 基于Java Servlet的Web应用设计源码
- Webots轮腿机器人,轮足机器人,五杆双足轮式机器人仿真,并联腿结构仿真 代码是c编写的,有详细的注释 提供完整模型以及代
- 光伏锂电池储能功率协调控制系统仿真 1左侧光伏Boost控制部分:采用扰动观察法来进行MPPT最大功率跟踪,其中可以改变光照
- 基于Java平台的货物管理设计源码
- 含压缩空气储能的冷热电联供微网运行优化策略matlab
- 基于多语言支持的茶叶信息检索系统设计源码
- 基于Spring Cloud+Vue技术架构的Shenhong-OA系统优化设计源码
- 基于Java语言的springDemo食谱项目设计源码
- 基于Python编写的spider_demo爬虫设计源码
- 基于大数据分析的京东服装用户消费画像设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页