IFC :: Playstation with DC motor code

This code is for control 2 DC Brush motor with PS2 controller for IFC board from cytron



    while(1)
       {   

          
         
          if(   ps_sw(ps_add,p_up)==0)
          {
				cp1_goto(0,0);				
				cp1_str("FORWARD");	
				cp1_goto(1,0);					
				cp1_str("POLIKK-BOT");		


		        bh_1_cw(add_bh);         
                bh_1_speed(add_bh,250);
                bh_2_cw(add_bh);
                bh_2_speed(add_bh,250);
             
           } else if( ps_sw(ps_add,p_cross)==0)
          {   
                     
             
                cp1_goto(0,0);				
				cp1_str("STOP   ");	
				cp1_goto(1,0);					
				cp1_str("POLIKK-BOT");		
                bh_1_brake(add_bh);
                bh_2_brake(add_bh);
             
          
           } else if(ps_sw(ps_add,p_down)==0) 
{
                cp1_goto(0,0);				
				cp1_str("REVERSE");
				cp1_goto(1,0);				
				cp1_str("POLIKK-BOT");		


		        bh_1_ccw(add_bh);        
                bh_1_speed(add_bh,250);
                bh_2_ccw(add_bh);
                bh_2_speed(add_bh,250);
             
          } else if(ps_sw(ps_add,p_left)==0) 
{
                cp1_goto(0,0);					
				cp1_str("LEFT   ");	
				cp1_goto(1,0);				
				cp1_str("POLIKK-BOT");	

		        bh_1_ccw(add_bh);         
                bh_1_speed(add_bh,250);
                bh_2_cw(add_bh);
                bh_2_speed(add_bh,250);
             
          } else if(ps_sw(ps_add,p_right)==0) 
{
                cp1_goto(0,0);					
				cp1_str("RIGHT  ");	
				cp1_goto(1,0);					
				cp1_str("POLIKK-BOT");		


		        bh_1_cw(add_bh);         
                bh_1_speed(add_bh,250);
                bh_2_ccw(add_bh);
                bh_2_speed(add_bh,250);
             
         }
       }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: