# Servo Motor Problems

Hi!

I am a high school student taking a Project Lead The Way, Principles Of Engineering course. In class, we are working on group projects with RobotC, but my group is having some trouble with our code. We’ve tried every troubleshooting technique that our teacher knows and he still can’t figure out what the problem is, so he suggested that we ask on this forum. We hope you can help us!

What has been happening is the servo motor hasn’t been turning to the value of salmon (-60), even though in the sensors tab we can see that the sonar value is less than 100 and the light sensor value is greater than 400. We have tested our servo motor in a separate program just to see if it works, and it does, so we’re not sure what is wrong.

Here’s our code:

#pragma config(StandardModel, “POE + CIM Testbed”)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

/*
Project Title: Project Tortuga
Team Members: Dani, Sophie, and Gautham
Date: August 31, 2017
Section: Period 6

Pseudocode:

*/
int potato= 60;
int salmon=-potato;
void compton ()
{
while (potato==potato)
{
if(potato<70)
{
startMotor(rightMotor, potato); //right motor starts
startMotor(leftMotor, potato);
wait(0.5);
potato=potato+1;
}
else
{
stopMotor(rightMotor);
stopMotor(leftMotor);
}
}
}

{ //Program begins, insert code within curly braces
while(potato==potato)
{
if(SensorValue(limitSwitch) ==0)
{
if(SensorValue(bumpSwitch)==1)
{
turnLEDOn();
wait(2);
startMotor(leftMotor, salmon);
}
}
else
{
compton();
}
if(SensorValue(sonar) <100 && SensorValue(lightSensor) >400)
{
setServo(salmon);
}
}
}

If you could take a look at this and help us out, it would be greatly appreciated.

Thanks!
~Dani Medvedovski

Try changing the setServo command to

``````
setServo(servoMotor, salmon);

``````

You have selected a standard robot configuration “POE + CIM Testbed”, the servo motor should be connected to port 9 on the cortex when using this configuration.

2 Likes