资源描述:
《51单片机交通灯程序及PROTEUS仿真集合》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、51单片机外接8255A做成的交通灯程序及PROTEUS仿真结果(附对应C语言程序)2010-04-2122:01CONTROLEQU7FFFHPORTAEQU7FFCHORG0START:MOVDPTR,#7FFFHMOVA,#80HMOVX@DPTR,AMOVDPTR,#7FFCHMOVA,#0FFHMOVX@DPTR,ALOOP:MOVA,#21HMOVDPTR,#7FFCHMOVX@DPTR,A;东西红,南北绿CALLDELAYLONGMOVA,#11HMOVDPTR,#7FFCHMOVX@DPTR,
2、A;三次闪烁CALLDELAYSHORTMOVA,#01HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#11HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#01HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#11HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#01HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSH
3、ORTMOVA,#0CHMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYLONGMOVA,#0AHMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#08HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#0AHMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#08HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#0AHMOVDPT
4、R,#7FFCHMOVX@DPTR,ACALLDELAYSHORTMOVA,#08HMOVDPTR,#7FFCHMOVX@DPTR,ACALLDELAYSHORTAJMPLOOPDELAYLONG:MOVR7,#40L1:MOVR6,#200L2:MOVR5,#250DJNZR5,$DJNZR6,L2DJNZR7,L1RETDELAYSHORT:MOVR4,#200L3:MOVR3,#250DJNZR3,$DJNZR4,L3RETENDC语言程序:#include#definePORTAX
5、BYTE[0X7FFC]#defineCONTROLXBYTE[0X7FFF]voidDELAYLONG(void);voidDELAYSHORT(void);voidmain(void){CONTROL=0x80;PORTA=0XFF;while(1){PORTA=0X21;DELAYLONG();PORTA=0X11;DELAYSHORT();PORTA=0X01;DELAYSHORT();PORTA=0X11;DELAYSHORT();PORTA=0X01;DELAYSHORT();PORTA=0X11
6、;DELAYSHORT();PORTA=0X01;DELAYSHORT();PORTA=0X0C;DELAYLONG();PORTA=0X0A;DELAYSHORT();PORTA=0X08;DELAYSHORT();PORTA=0X0A;DELAYSHORT();PORTA=0X08;DELAYSHORT();PORTA=0X0A;DELAYSHORT();PORTA=0X08;DELAYSHORT();}}voidDELAYLONG(void){unsignedi,j,k;for(i=0;i<20;i++
7、)for(j=0;j<40;j++)for(k=0;k<2500;k++);}voidDELAYSHORT(void){unsignedi;for(i=0;i<30000;i++);}===========================================#includeunsignedchari=0,j=0;unsignedcharcount=0,m,n;unsignedchartemp;unsignedcharcodep3[]={0x01,0x02,0x04,0x08,0x
8、10,0x20,0x40,0x80};unsignedcharcodep1[]={0,1,2,3,4,5,6,7,8,9};unsignedcharcodetemp1[][4]={6,9,18,27,3,3,12,21,27,6,9,18,21,3,3,12,18,27,6,9,12,21,3,3,9,18,27,6,3,12,21,3};voidmain(){EA=1;TH0=(65536-250