Exemple #1
0
/*******************************************************************
* Function:			int waitButton(void)
* Input Variables:	none
* Output Return:	int
* Overview:			Use a comment block like this before functions
********************************************************************/
int WaitButton( void ) 
{
    BOOL btnState1, btnState2, btnState3;//local variables - button states
	//int rtnValue=0;//return the button value
	int rtnValue=0;

	LCD_clear();

	if((ATopstat.state=SUBSYS_OPEN))
	{
       		// Get switch states.
		btnState1 = ATTINY_get_SW_state( ATTINY_SW3 );
		btnState2 = ATTINY_get_SW_state( ATTINY_SW4 );
		btnState3 = ATTINY_get_SW_state( ATTINY_SW5 );
		//LCD_printf("btnStates: %d %d %d \n", btnState1, btnState2, btnState3);

		if( btnState1 == TRUE ) 
		{
			LCD_printf( "SW1: Pushed\n");
			// TMRSRVC_delay(500);//wait 1 s

	                // Assume the LED subsystem opened successfully.
        	        LED_set_pattern( 0b00100000 );//turn the red LED on
                	TMRSRVC_delay(500);//wait 2 seconds
               		LED_clr_pattern( 0b01000000 );//turn the green LED off
                	LED_clr_pattern( 0b00100000 );//turn the red LED off
			rtnValue=1;
			}//end if button 1 state open

		if( btnState2 == TRUE ) 
		{
			LCD_printf( "SW2: Pushed\n");
			// TMRSRVC_delay(500);//wait 1 s

	                // Assume the LED subsystem opened successfully.
        	        LED_set_pattern( 0b01000000 );//turn the green LED on
                	TMRSRVC_delay(500);//wait 2 seconds
                	LED_clr_pattern( 0b01000000 );//turn the green LED off
                	LED_clr_pattern( 0b00100000 );//turn the red LED off
			rtnValue=2;
		}//end if btn 2 open

		if ( btnState3 == TRUE ) 
		{
			LCD_printf( "SW3: Pushed\n");
			// TMRSRVC_delay(500);//wait 1 s

	                // Assume the LED subsystem opened successfully.
        	        LED_set_pattern( 0b01000000 );//turn the green LED on
                	LED_set_pattern( 0b00100000 );//turn the red LED on
                	TMRSRVC_delay(500);//wait 2 seconds
                	LED_clr_pattern( 0b01000000 );//turn the green LED off
                	LED_clr_pattern( 0b00100000 );//turn the red LED off
			rtnValue=3;
		}//end if btn 3 open
            	LCD_clear();
		return rtnValue;
	}//end AT while

}//end the WaitButton() function
Exemple #2
0
 /*******************************************************************
* Function:			int EnterCommandButton(void)
* Input Variables:	none
* Output Return:	int
* Overview:			Use a comment block like this before functions
********************************************************************/
int EnterTopoCommand( void ) 
{
    BOOL btnState1, btnState2, btnState3;//local variables - button states
	//int rtnValue=0;//return the button value
	int rtnValue=0;

	if((ATopstat.state=SUBSYS_OPEN))
	{
       	// Get switch states.
		btnState1 = ATTINY_get_SW_state( ATTINY_SW3 );
		btnState2 = ATTINY_get_SW_state( ATTINY_SW4 );
		btnState3 = ATTINY_get_SW_state( ATTINY_SW5 );
		
		//LCD_printf("btnStates: %d %d %d \n", btnState1, btnState2, btnState3);
		if( btnState1 == TRUE )
		{
			rtnValue=1;
			}//end if button 1 state open

		if( btnState2 == TRUE ) 
		{
			rtnValue=2;
		}//end if btn 2 open

		if ( btnState3 == TRUE ) 
		{
			rtnValue=3;
		}//end if btn 3 open
		return rtnValue;
	}//end AT while

}//end the WaitButton() function
Exemple #3
0
void CBOT_main(void)
{
	STEPPER_open(); // Enables control of the steppers
	ATTINY_open(); // Enables reading of the buttons
	SPKR_open(SPKR_BEEP_MODE); //enables beeping
	LCD_open(); // Enables use of the LCD
	ADC_open();//open the ADC module
	
	
	while(1)
	{
		if(ATTINY_get_SW_state(ATTINY_SW3))
		{
			smartGoToGoal(4,4);
		}
		if(ATTINY_get_SW_state(ATTINY_SW4))
		{
			wander('a');
		}
		if (ATTINY_get_SW_state(ATTINY_SW5))
		{
			char wall = 'l';
			while(wall=='l'){
				wall = wallFollow('l',4,5,10);
			}
			
		}
		//TODO:: Please write your application code
	}
}
Exemple #4
0
void wander(char type)
{
	if(type == 'a')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = aggressiveKid(1,6,3);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
	}
	if(type=='s')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = shyGuy(1,7,4,4,6);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
	}
	
}
Exemple #5
0
void levelZero(char type,float frontDist)
{
	if(type == 'a')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = aggressiveKid(0,6,3);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
		
	}
}