go_away

Author Topic: Servo Stop Position  (Read 1783 times)

0 Members and 1 Guest are viewing this topic.

Offline MilesTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 1
Servo Stop Position
« on: January 30, 2009, 05:25:49 AM »
Hi, i have built the $50 robot and all is fine, but i just want to know something in relation to the code.

To make the robot go forward is:

   servo_left(25);
   servo_right(44);


But what number do i have to replace either number to make to servos stop rotating? e.g Servo_left(???)

Thanks,

Offline byuri

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: Servo Stop Position
« Reply #1 on: January 30, 2009, 05:34:05 AM »
if you want to stop the servo, just don't call the function [servo_left\right]  =)
or try to send 35 or 34 to the function. e.g servo_left(35)

Offline MilesTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 1
Re: Servo Stop Position
« Reply #2 on: January 30, 2009, 05:47:26 AM »
Ok thanks, i think taking out the command may be easier.

This is my situation:


LED_on();//turn LED on


   while(1)
   
      if(sensor > 90)
         {//go forward
         servo_left(25);
         servo_right(44);
         }

      else if(sensor < 80)
         {//go backward
         servo_left(44);
         servo_right(25);


      else
         {//do nothing
         servo_left(35);
         servo_right(35);
         }

Could i just replace the last bit with             

                                 else

                                          {
                                             LED_off();
                                          }


or something like that? If i were to have the LED_off() in the last bit would i need to move the LED_on() bit at the start to somewhere below the while(1) part?

Offline byuri

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: Servo Stop Position
« Reply #3 on: January 30, 2009, 11:03:24 AM »
you dont need the last 'else' because if sensor data between 80-90 the robot do nothing.
if you want that the led will turn off when your robot stops and led on when robot in moving, try next code..
sorry about my English, i hope you understand me.

while(1)
   {
      if(sensor > 90)
         {//go forward
         servo_left(25);
         servo_right(44);
         LED_on();
         }

      else if(sensor < 80)
         {//go backward
         servo_left(44);
         servo_right(25);
         LED_on();
         }

      else
         {//do nothing
         LED_off();         
         }
}

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Servo Stop Position
« Reply #4 on: January 30, 2009, 11:08:00 AM »
If you put the servos to their center positions they will stop. Please try using the forumla included in the code at the bottom

Offline MilesTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 1
Re: Servo Stop Position
« Reply #5 on: January 30, 2009, 05:59:13 PM »
Great, thanks for all of the replies you really helped me out

 


Get Your Ad Here