文档介绍:计算机学院学院计算机科学与技术班__组学号3姓名杨协作者______________教师评定_______________实验题目单片机I/O——流水灯一、。。。。二、,参照“二、实验电路”绘制仿真原理图。:(1).从VD1~VD32逐次点亮每个LED,然后熄灭。每个LED亮灯时间约200ms。(2).点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。(3).在全部灯亮的情况下,从VD1~VD32逐次熄灭LED,熄灭VD1,延时200ms;然后熄灭VD2,延时200ms……熄灭VD32,全部灯被熄灭。(4).重复上述过程。三、实验电路4、实验源程序#include<>/*包括P0~P3口在内的89C52特殊功能寄存器定义*/#defineucharunsignedchar#defineuintunsignedintucharcodefun[]={0xfe,0x7f,0x01};voiddelay()//延时函数{uchari,j;for(i=0;i<200;i++)for(j=0;j<200;j++);}voidfun1()//依次从VD1~VD32点亮LED灯,{ucharj,i=0; uchartemp; temp=fun[i]; for(j=0;j<8;j++) {P0=temp;temp=temp<<1; temp|=0x01; delay(); } P0=0xff;//灭P0口灯 temp=fun[i];//然后依次点亮LED灯 for(j=0;j<8;j++) {P1=temp; temp=temp<<1; temp|=0x01; delay(); } P1=0xff;//灭P1口灯 temp=fun[i];//然后依次点亮LED灯 for(j=0;j<8;j++) {P2=temp; temp=temp<<1; temp|=0x01; delay(); } P2=0xff;//灭P2口灯 temp=fun[i];//然后依次点亮LED灯 for(j=0;j<8;j++) { P3=temp; temp=temp<<1; temp|=0x01; delay(); } P3=0xff;//灭P3口灯}voidfun2()//依次从VD32~VD31点亮LED灯{ ucharj,i=1; uchartemp; temp=fun[i]; for(j=0;j<8;j++) { P3=temp; temp=temp>>1;// temp|=0x80; delay(); }// P3=0xff; temp=fun[i]; for(j=0;j<8;j++) { P2=temp; temp=temp>>1;// temp|=0x80; delay(); }// P2=0xff; temp=fun[i]; for(j=0;j<8;j++) { P1=temp; temp=temp>>1;//temp|=0x80; delay(); }//