找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 1432|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

基于51單片機(jī)的交通燈設(shè)計(jì)

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:693950 發(fā)表于 2020-2-18 16:12 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式

#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit RED_A=P0^0;
sbit YELLOW_A=P0^1;
sbit GREEN_A=P0^2;
sbit RED_B=P0^3;
sbit YELLOW_B=P0^4;
sbit GREEN_B=P0^5;
uchar Time_Count=0;
Flash_Count=0;
Operation_Type=1;
void To_int()interrupt 1
{
  TH0=-50000/256;
  TL0=-50000%256;
  switch(Operation_Type)
  {
   case 1;
          RED_A=0;YELLOW_A=0;GREEN_A=l;
                  RED_B=l;YELLOW_B=0;GREEN_B=0;
                  if(++Time_Count!=100)
                   retun;
                  Time_ Count=0;
                  Operation_Type=2;
                  break;
   case 2:
       if(++Time_Count!=8)retun;
           Time_Count=0;
           YELLOW_A=!YELLOW_A;
           GREEN_A=0;
           if(++Flash_Count!=10)
           retun;
           Flash_ Count=0;
           Operation_Type=3;
           break;
void main()
{
TMOD=0x01;
IE=0x82;
TR0=l;
while(1);
}



放一下我的程序

新建文件夾.zip

20.65 KB, 下載次數(shù): 6, 下載積分: 黑幣 -5

hex文件。.c文件

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表