/*******************************************************************************
* 函 数 名 :main
* 函数功能 :主函数
* 输    入 :无
* 输    出 :无
*******************************************************************************/
void main()
{
	UsartConfiguration();
	printf("system begin\r\n");
	Timer0Init();
	Exit0Init();
	SystemInit();	
	
	while(1)
	{
		KeyScan();
		Display(ratio_value);
//		if(motor_count >= 5000)//每隔5s反转一次
//		{
//			motor_count = 0;
//			motor_dir = !motor_dir;
//			printf("system switch dir\r\n");
//		}
		if(time1s_tick>= 2000)
		{
			time1s_tick = 0;
			printf("%d %d\r\n",coder_count,motor_count);
		}
	}	
}
Esempio n. 2
0
/*******************************************************************************
* 函 数 名 :main
* 函数功能 :主函数
* 输    入 :无
* 输    出 :无
*******************************************************************************/
void main()
{
	UsartConfiguration();
	while(1)
	{
		
	}	
}
void main()
{
	int i;
	UsartConfiguration();			  
	while(1)
	{			  
		DigDisplay();
	}		    
}
Esempio n. 4
0
/*******************************************************************************
* 函 数 名 :main
* 函数功能 :主函数
* 输    入 :无
* 输    出 :无
*******************************************************************************/
void main()
{
	CarStop();	
	LED_OFF;
	UsartConfiguration();
	LCD1602Init();
	Timer0Init();
	
	//5ms 执行一次
	while(1)
	{ 
		if(tick_5ms >= 5)
		{
			tick_5ms = 0;
			tick_200ms++;
			if(tick_200ms >= 40)
			{
				tick_200ms = 0;
				if(switch_flag)
				{
					LED_ON;
					switch_flag = 0;
				}else
				{
					LED_OFF;
					switch_flag = 1;				
				}
			}
			
			continue_time--;//200ms 无接收指令就停车
			if(continue_time == 0)
			{
				continue_time = 1;
				CarStop();
			}
			//do something
			if(bt_rec_flag == 1)//接收到红外信号
			{
				bt_rec_flag = 0;
				switch(ctrl_comm)
				{
					case COMM_UP:    CarGo();break;
					case COMM_DOWN:  CarBack();break;
					case COMM_LEFT:  CarLeft();break;
					case COMM_RIGHT: CarRight();break;
					case COMM_STOP:  CarStop();break;
					default : break;
				}
				LCD1602WriteCommand(ctrl_comm);
				//printf("%c",ctrl_comm);
			}
		}
	}
}