当前位置:网站首页>Simple operation of running water lamp (keil5)

Simple operation of running water lamp (keil5)

2022-07-05 07:18:00 After reading thousands of books, you can pick them up and put

Make the running water light turn on at first and then turn off three times ( Full flash three times ), Then light it in turn , Then go out in turn .

#include <STC15F2K60S2.H>
#define close P2=0x1f&(P2|0xe0);// Close the latch (y4,y5,y6,y7)
/***************************************************/

void initsystem(unsigned char i)
{
    
	switch(i)
	{
    
		case 4:
			P2=0X8f&(P2|0xe0);// open y4 Latch 
		break;
		case 5:
			P2=0xbf&(P2|0xe0);// open y5 Latch 
		break;
		case 6:
			P2=0xdf&(P2|0xe0);// open y6 Latch 
		break;
		case 7:
			P2=0xff&(P2|0xe0);// open y7 Latch 
		break;
	}
}
/***********************************************/

void led_control(unsigned char n,unsigned char q)// Control lights (p0 End , Latch )
{
    
	initsystem(q);
	P0 = n;
}
/*******************************************/

void Delay (unsigned int t)// Time delay 
{
    
	while(t--);
	while(t--);
}
/********************************************/

void LED_Running ()// Running lights 
{
    
	unsigned char i;
	for (i=0;i<3;i++)// All lights are on and off 3 Time 
	{
    
		led_control(0x00,4);
		Delay (60000);
		led_control(0xff,4);
		Delay (60000);

	}
	for(i=1;i<8;i++)// The lights come on in turn 
	{
    
		led_control(0xff<<i,4);
		Delay(60000);

	} 
	for(i=1;i<8;i++)// The lights go out in turn 
	{
    
		led_control(~(0xff<<i),4);
		Delay(60000);

	}
}
/**********************************************/

void main()// The main function 
{
    
	led_control(1,4);close;// initialization 
	led_control(0x00,5);close;// initialization 
	while(1)
	{
    
		LED_Running ();
	}
}

原网站

版权声明
本文为[After reading thousands of books, you can pick them up and put ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140558148831.html