⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text1.c

📁 我的一个交通灯的课程设计
💻 C
字号:
#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
sbit Sred_Egeeen=P1^1; 
sbit Syellow_Eyellow=P1^2;
sbit Sgreen_Ered=P1^3;//定义南北、东西向端口
void delay(unsigned char k);//函数声明
unsigned char count;//定义全局变量
void time0_int(void) interrupt 1
  {
    count=count+1;
				 }

void main(void)
{ 
  TMOD=0X00;//工作方式0 8.192ms
  TH0=0X00;
  TL0=0X00;
  EA=1;
  ET0=1;
  TR0=1;
  while(1)
  {
    count=0;
    Sred_Egeeen=0;
	 Syellow_Eyellow=1;
	 Sgreen_Ered=1;
    do{;}
	 while(count<=250);//南北红灯,东西绿灯
	 Sred_Egeeen=1;
	 Syellow_Eyellow=0;
	 Sgreen_Ered=1;
	 count=0;
	 do{;}
    while(count<=40);//黄灯切换
    Sred_Egeeen=1;
	 Syellow_Eyellow=1;
	 Sgreen_Ered=0;
	 count=0;
	 do{;}
    while(count<=250);//南北绿灯,东西红灯*/
	 power=1;
	 }
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -