Society of Robots - Robot Forum

Software => Software => Topic started by: ballbreaker on July 14, 2010, 06:53:55 AM

Title: how can i make 50$ robot with sharp IR stop when 10cm from target?
Post by: ballbreaker on July 14, 2010, 06:53:55 AM
what are the commands? also how can i make it to stop and turn away when facing wall (doesn't have to follow objects.)
Title: Re: how can i make 50$ robot with sharp IR stop when 10cm from target?
Post by: Choco_liger on July 14, 2010, 06:59:16 AM
Heh. That's what I'm doing now.

Title: Re: how can i make 50$ robot with sharp IR stop when 10cm from target?
Post by: ballbreaker on July 14, 2010, 08:40:57 AM
well any tips?
Title: Re: how can i make 50$ robot with sharp IR stop when 10cm from target?
Post by: Conscripted on July 14, 2010, 11:06:14 AM
It should be as simple as finding the sharp's output at 10cm and then use that as your threshold value.

Conscripted
Title: Re: how can i make 50$ robot with sharp IR stop when 10cm from target?
Post by: ballbreaker on July 16, 2010, 03:12:59 PM
will this work to follow an object and when its too close to turn?

   while(1)
      {
      scan();
      
      //object on left
      if(scan_angle > 57 && sharp_IR_reading > scan_thresh)
         robot_turn_left();

      //object on right
      else if(scan_angle < 41 && sharp_IR_reading > scan_thresh)
         robot_turn_right();
   
       // object at close distance
      else if(sharp_IR_reading == scan_thresh)
          robot_turn_left();
        
            
      //object is centered
   else if(sharp_IR_reading > scan_thresh && scan_angle >41 <57)
      robot_go_straight();
         
delay_cycles(400);

}

can anyone find any errors or if this would work as an idea?