/********************************************

实验名称:Led发光管实验一

实验目的:用位操作和总线操作点亮第一个发光管

********************************************/


#include<reg52.h>


//sbit P10 = P1^0;


//void delay_1ms(int);


void main()

{

while(1)         //进入大循环

{

//P10 = 0;

P1 = 0xfe;   //第一位低电平

}

}


/********************************

函数名称:delay_1ms

函数功能:延时1ms左右的时间

函数参数:int x

返回值:  void

********************************/

//void delay_1ms(int x)

//{

//int i, j;

//for(i = 0; i < x; i++)

//{

//for(j = 0; j < 110; j++);

//}

//}


/*********************************************

实验名称:Led发光管实验二

实验目的:用位操作和总线操作点亮第一三五七发亮

*********************************************/


#include<reg52.h>


sbit P10 = P1^0;

sbit P12 = P1^2;

sbit P14 = P1^4;

sbit P16 = P1^6;


void main()

{

while(1)

{

/*P10 = 0;

P12 = 0;

     P14 = 0;

P16 = 0;*/

P1 = aa;

}

}


/************************************

实验名称:Led发光管实验四

实验目的:第一个发光管以间隔200ms闪烁

************************************/

#include<reg52.h>


sbit P10 = P1^0;


void delay_1ms(int);


void main()

{

while(1)

{

P10 = 0;

delay_1ms(200);

P10 = ~P10;

delay_1ms(200);

}

}


/********************************

函数名称:delay_1ms

函数功能:延时1ms左右的时间

函数参数:int x

返回值:  void

********************************/

void delay_1ms(int x)

{

int i, j;

for(i = 0; i < x; i++)

{

for(j = 0; j < 110; j++);

}

}