【正文】
s3 = 10。 s = 1。 while(IE1 ==1)。 P0 = 0。 P0 = 0xff。 //設(shè)置所有車道燈為紅燈 P3 = 0xbd。 } if(s == 4) //換向設(shè)置通行時(shí)間 { sec = s4。//黃燈閃爍標(biāo)志 } if(sec == 0) //倒計(jì)時(shí)到了0秒,此時(shí)要切換下個(gè)狀態(tài) { yellowflag = 0。 s2 = 10。 s2 = 10。 s4 = 20。amp。 s2 = 10。 if(time == 24) time = 0。 //清零 sec 。 //設(shè)置定時(shí)時(shí)間為50MS t ++ 。 P0 = 0。 P0 = 0xff。 delay(3)。 wela = 1。 //前面四行實(shí)現(xiàn)黃燈閃爍 dula = 1。 } /****************狀態(tài)S4,黃燈亮********************/ if((s == 4)amp。 P0 = 0xdf。 P0 = table[(sec yellowtime) % 10]。 wela = 0。 //顯示紅燈的十位 dula = 0。 P0 = 0。 P0 = 0xff。 delay(3)。 wela = 1。 //設(shè)置燈 dula = 1。 delay(3)。 wela = 1。 dula = 1。 P0 = 0xee。 P0 = table[sec/10]。amp。 wela = 0。 //顯示紅燈的個(gè)位 dula = 0。 P0 = 0。 P0 = 0xff。 delay(3)。 wela = 1。 dula = 1。 P0 = 0xfe。 P0 = table[(sec yellowtime)/10]。amp。 wela = 0。 dula = 0。 P0 = 0。 P0 = 0xff。 //前面四行實(shí)現(xiàn)黃燈閃爍 P3 = 0xbe。amp。 wela = 0。 //顯示紅燈的個(gè)位 dula = 0。 P0 = 0。 P0 = 0xff。 delay(3)。 wela = 1。 dula = 1。 P0 = 0xfe。 P0 = table[(sec / 10)]。amp。 wela = 0。 dula = 0。 P0 = 0。 P0 = 0xff。 //車道黃燈開 P3 = 0xed。amp。 wela = 0。 //顯示紅燈的個(gè)位 dula = 0。 P0 = 0。 P0 = 0xff。 delay(3)。 wela = 1。 dula = 1。 //打開位鎖存器 P0 = 0xfe。 //打開段鎖存器 P0 = table[(sec yellowtime)/10]。amp。 //總中斷使能 ET0 = 1。 TMOD = 0x01。 IT1 = 0。 s1 = 15。 g = 0。}void init() //初始化函數(shù) { half_sec = 0。x0。bit g。參 考 文 獻(xiàn)(第三版).北京::彭冬明,: ::溫欣玲,. 微計(jì)算機(jī)信息,23(10):9091胡漢才. :清華大學(xué)出版社.周美珍,9(20):2021蔣汝根,6(6):812康華光,(模擬部分).北京:高等教育出版社康華光,(數(shù)字部分).北京:高等教育出版社(第三版).北京:張偉,王麗, :Intelligence Traffic lights Control System Based on Single Chip Micyoco (College of Engineering, South China Agricultural University, Guangzhou 510642, China)Abstract: The traffic light is an essential part of modern transportation. A reliable traffic light system plays a key role for improving urban transportation efficiency and lowering traffic accident odds.The system consists of SCM, duplicate power supply system, traffic light demonstration system and interruption system.Considering the universal property, it chooses single chip as the main control chip. Universal property means that circuit and programming language are easier and more mon which rely on the single chip than that of other control chip. It is simpler and more convenient to add more functions and maintain the system. Inexpensive means that the single chip costs less than other control chip. A STC89C52 costs less than 10RMB. it costs less than 100RMB even pulsing peripheral circuits. In this way it can control the developing cost and maintenance cost. So, this system chooses STC89C52 as control chip.This system adopts a dual power supply system, just as the main and backup power supply. Dual power supply scheme is mainly in response to a sudden powerdown or mains failure situation. It is significant for holding the system work continually. The principle is to use oneway diode switch conductive feature to achieve dual power switching instantaneously. Interrupt system is to achieve the function of a specific need in the case of special needs of the system. These states include all the red and high or low peak switch immediately.This system not only achieves the most basic features of a traffic light, but also implements high and low peak time sharing control scheme to deal with the different periods of different cities in traffic conditions. The traffic flow achieves its maximum in the morning and evening. So the sharedtime of control has a very important role for improving urban transport efficiency. Keywords: Single Chip STC89C52 Traffic Light TimeShared System Duplicate power 附錄一 系統(tǒng)主板電路圖附錄二 程序清單/******************************************************本交通燈實(shí)現(xiàn)的功能:正常時(shí)可以分時(shí)段車流高峰與低峰進(jìn)行控制可以緊急控制,讓某些車通過可以人為設(shè)置為車流高峰區(qū)狀態(tài)******************************************************/include include define uchar unsigned chardefine uint unsigned intuchar t