⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 这里有很多我自己做的凌阳单片机源程序
💻 C
字号:
#include<spce061a_chf.h>
#include"bit.h"
#include"qiao3.h"
extern sec;
int main(void)
{
	unsigned int key_value=0;
	unsigned int end_flag=0;
	init_IO();
	display(0);
	while(key_value==0)
	{
		key_value=key_scanf();		
	}
	asm("irq on");
	while(1)
	{
		sec=0;
		if(key_value==1)
		{
			zonghe();
		}
lab1:	while((P1_0==0)|(P1_1==0))
		{
			if((P1_5==1)|(P1_4==1))
			{
				goto dd;				
			}
			else
			{
				control_up();
				*P_Watchdog_Clear=0x01;
			}
		}
dd:		while(P1_4==1)
		{
			control_right();
			*P_Watchdog_Clear=0x01;
		}
		while(P1_5==1)
		{
			control_left();
			*P_Watchdog_Clear=0x01;
		}
		control_stop();
		delay();
		delay();
		delay();	
		*P_Watchdog_Clear=0x01;
		if((P1_0==0)|(P1_1==0))
		{
			goto lab1;
		}
		sec=0;
		control_up();
		delay();
		control_stop();
		*P_Watchdog_Clear=0x01;
lab2:	while((P1_0==1)|(P1_1==1))
		{
			control_goback();
			delay();
			*P_Watchdog_Clear=0x01;
			control_stop();
			delay();
			delay();
			*P_Watchdog_Clear=0x01;
		}
		while((P1_2==1)|(P1_3==1))
		{
			control_up();
			//delay();
			delay();
			*P_Watchdog_Clear=0x01;
			control_stop();
			delay();
			delay();
			*P_Watchdog_Clear=0x01;
		}		
		if(sec<15)//
		{				
			goto lab2;		
		}	
		else if((sec>=15)&(sec<22))
		{
			P1_15=1;
			goto lab2;
		}	
		sec=0;
		P1_15=1;
		P1_15=1;
		P1_15=1;
		P1_15=1;
lab3:	while((P1_4==0)&(P1_5==0))
		{	
			control_up();
			P1_15=0;				
			*P_Watchdog_Clear=0x01;			
		}
		control_stop();
		delay();		
		if(P1_4==1)
		{
			control_up();
			delay();
			*P_Watchdog_Clear=0x01;
			control_stop();
			if(P1_5==0)
			{				
				while(P1_4 ==1)
				{
					control_right();
					*P_Watchdog_Clear=0x01;
				}
				control_stop();
			}
			else
			{
				end_flag=1;
			}
		}
		else if(P1_5==1)
		{
			control_up();
			delay();
			control_stop();
			if(P1_4==0)
			{
				while(P1_5==1)
				{
					control_left();
					*P_Watchdog_Clear=0x01;
				}
				control_stop();				
			}
			else
			{
				end_flag=1;
			}
		}
		
		if((P1_0==0)|(P1_1==0))
		{
			goto lab2;
		}
		if(end_flag==0)
		{
			goto lab3;
			sec=0;
		}
		control_stop();//到达B端
		sec=0;
		while(sec<5);
		sec=0;
		end_flag=0;
lab4:	while((P1_6==0)&(P1_7==0))
		{
			control_goback();
			*P_Watchdog_Clear=0x01;
		}
		if(P1_6==1)
		{
			control_goback();
			delay();
			if(P1_7==0)
			{
				while(P1_6==1)
				{
					control_right();
				}
				control_stop();
			}
			else
			{
				end_flag=1;
			}
		}
		if(P1_7==1)
		{
			control_goback();
			delay();
			if(P1_6==0)
			{
				while(P1_7==1)
				{
					control_left();
					*P_Watchdog_Clear=0x01;
				}
				control_stop();
			}
			else
			{
				end_flag=1;
			}
		}
		if(end_flag==0)
		{
			goto lab4;
		}
		while(1)//走完全程后在此循环
		{
			control_stop();
			*P_Watchdog_Clear=0x01;
		}		
	}
	return 0;
}
					

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -