View unanswered posts | View active topics It is currently Tue Oct 21, 2014 11:13 am






Reply to topic  [ 2 posts ] 
Need help programming servos to move... 
Author Message
Rookie

Joined: Sat Nov 17, 2012 3:59 pm
Posts: 2
Post Need help programming servos to move...
I have two servos I need to move only while a touch sensor is pressed. Since you have to specify a position value for it to reach, I have no clue how to accomplish this. Also is there a way to slow the servo rate down? I tried ServoChangeRate and set it to 1 but it still ran at full speed.


Tue Jan 01, 2013 7:01 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Need help programming servos to move...
One way to do it is to implement your own servo rate. For example:
Code:
#define SERVO_LOW_LIMIT    0
#define SERVO_HI_LIMIT     160

int servoPos = SERVO_LOW_LIMIT;
while (true)
{
    if (SensorValue[touchSensor] != 0)
    {
        servoPos += 20;
        if (servoPos > SERVO_HI_LIMIT)
        {
            servoPos = SERVO_HI_LIMIT;
        }
        servo[servoMotor] = servoPos;
    }
    wait1Msec(100);
}

The downside is that the motion may be jerky but it should work.


Tue Jan 01, 2013 9:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.