Beispiel #1
0
int main() {
     
     
     printf("Online%\n\r");
     
     wait_ms(500);
     
     w1_cha.fall(&count_w1_a);
     w1_chb.fall(&count_w1_b);
     
     w2_cha.fall(&count_w2_a);
     w2_chb.fall(&count_w2_b);
     
     /* test maneuvers */
     forward();
     backward();
     
     turnr();  
     turnl();
     turnl();
     
     square();
     
    while(1) {

         if (w1_count_a != w1_dif_a){
        
         w1_dif_a = w1_count_a;
        printf("w1 count a = %d\n\r", w1_dif_a);
        }

        if (w1_count_b != w1_dif_b){
         w1_dif_b = w1_count_b;
        printf("w1 count b = %d\n\r", w1_dif_b);
        }
        
        if (w2_count_a != w2_dif_a){
        
         w2_dif_a = w2_count_a;
        printf("w2 count a = %d\n\r", w2_dif_a);
        }

        if (w2_count_b != w2_dif_b){
         w2_dif_b = w2_count_b;
        printf("w2 count b = %d\n\r", w2_dif_b);
        }
        myled = !myled;
    }
}
int main()
{
	create_connect();
	go(457.2,250);
	resetd();
	while (get_create_total_angle(10) < 90)
		{turnl(250);}
	reseta();
	go(457.2,250);
	resetd();
	while (get_create_total_angle(10) > -90)
		{turnr(250);}
	reseta();
	go(250,250);
	while (get_create_total_angle(10) > -90)//Riddhi..your job is to write a 
		//function like mine, go, that makes an easy command to turn the robot.
		{turnr(250);}
	reseta();
	go(400,250);
	resetd();
	motor(3,50);
	sleep(1.5);//this is to lower the cage thing for the green 
		//and pink containers. might have to go forward or backward.
	go(-400,250);//to go backwards
	resetd();
	while (get_create_total_angle(10) < 90)
		{turnl(250);}
	reseta();
	go(-457.2,250);
	resetd();
	//need help with steps 13-21 on the pseudocode.
	while (analog(2) < 100)
		{create_drive_straight(250);} //to raise the cage, and leave the filled containers of luggage.
	motor(3,50);
	sleep(1.5);
	enable_servos();
	get_servo_position(2);
	if (get_servo_position(2) > 1023)
		{set_servo_position(2,get_servo_position(2)-1023);}
	if (get_servo_position(2) < 1023)
		{set_servo_position(2,get_servo_position(2)+1023);}
	

}
Beispiel #3
0
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);

	Int i;
	for (i = 0; i < N; i++){
		zensin(KYORI);
		turnl(KAKUDO);
	}

	return 0;
}
Beispiel #4
0
int main() {
     
     
     printf("Online%\n\r");
     
     wait_ms(500);
     
     /*inturupts*/
     w1_cha.fall(&count_w1_a);
     w1_chb.fall(&count_w1_b);
     
     w2_cha.fall(&count_w2_a);
     w2_chb.fall(&count_w2_b);
    
     
    c_forward(); //sets the robot to go forward
  
     
    while(1) {
        
        s1_check = s1;
        s2_check = s2;
        s3_check = s3;
        //s4_check = s4;

         if(s1_check != 1)
         {
          printf("S1 Hit \n\r");
        
         }
         
         if(s2_check != 1)
         {
          printf("S2 Hit \n\r");
        
         }
         
         if(s3_check != 1)
         {
          printf("S3 Hit \n\r");
        
         }
         
        // if(s4_check != 1)
         //{
          //printf("S4 Hit \n\r");
        
         //}
        
         if (w1_count_a != w1_dif_a){
        
         w1_dif_a = w1_count_a;
        printf("w1 count a = %d\n\r", w1_dif_a);
        }

        if (w1_count_b != w1_dif_b){
         w1_dif_b = w1_count_b;
        printf("w1 count b = %d\n\r", w1_dif_b);
        }
        
        if (w2_count_a != w2_dif_a){
        
         w2_dif_a = w2_count_a;
        printf("w2 count a = %d\n\r", w2_dif_a);
        }

        if (w2_count_b != w2_dif_b){
         w2_dif_b = w2_count_b;
        printf("w2 count b = %d\n\r", w2_dif_b);
        }
        
        
        
        /*goes backwards if it hits a detects a wall*/
        if (s1 != 1 && s2 !=1)
        {
            backward();//to correct when aligning
            c_backward();
            
        }
        
        
        /*goes forwards when detecting the wall*/
        if (s3 != 1){ 
          c_forward();
           
            }
        
        /*tries to aligin with the wall*/
        if (s1 != 1 && s2 != 0)
        {
            while(s1 != 1 && s2 != 0){
            c_right();    
            }
            backward();
            //dir = 0;
            //c_backward();
            
        }
        
        /*tries to aligin with the wall*/
         if (s1 != 0 && s2 != 1)
        {
             while(s1 != 0 && s2 != 1){
            c_left();    
            }
            backward();
            //dir = 0;
            //c_backward();
        }
        
        /*if all sensors triggured tries to turn to escape*/
        if (s1 != 1 && s2 != 1 && s3 != 1)
        {
           turnl(); 
        }
        
        /*if no senors triggred tries to contiue on*/
       if (s1 != 0 && s2 != 0 && s3 != 0)
        {
           if (dir == 0){
               c_backward();
               }
            else{
                c_forward();
                }
        }
        
        
    }
}