Help with Arm Coding and Understanding

Hi, I’m currently struggling to understand how to code the sensors and successfully move my robot’s arm up and down. (I’m a beginner)

So I am successfully able to move my robot forward and backward fairly easily. However, my robot’s arm won’t go up. When I press button 6U on the controller, it responds but doesn’t move. What I’m trying to say is you can see the motor working and the arm trying to go up but it just isn’t happening.

I’m not quite sure how to use the encoders, potentiometers, or ultrasonic sensors as well. I have a general idea of what they do, just not sure how to code them.

I was just playing around with the code below, trying to make my arm move. Is there a coding issue on why my arm is not going up? Or is it just a real-world issue with my robot?

Code:

#pragma config(Sensor, in2,    potent,         sensorPotentiometer)
#pragma config(Sensor, dgtl2,  limit,          sensorTouch)
#pragma config(Motor,  port2,           rightMotor,    tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port3,           leftMotor,     tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port6,           armMotor,      tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


task main()
{

	while(vexRT[Btn7D] == 0) // while button 7D is not pressed...
	{												 // do nothing until button 7d is pressed
	}

	// Remote Control Code
	clearTimer(T1);
	while(time1[T1] < 90000)

			{

				motor[leftMotor] = vexRT[Ch3] / 2;
				motor[rightMotor] = vexRT[Ch2] / 2;

				// Arm Control Code
				if(vexRT[Btn6U]  == 1 && SensorValue[potent] < 1200)
				{
					motor[armMotor] = 40;
				}
				else if(vexRT[Btn6D] == 1 && SensorValue(limit) == 0)
				{
					motor[armMotor] = -40;
				}
				else
				{
					motor[armMotor] = 0;
				}

			}

	motor[leftMotor] = 0;
	motor[rightMotor] = 0;

}

Are you sure it’s not a mechanical problem? As in, are you actually providing enough power to lift the arm?

Yes, my robot is built off instructions given to me by a teacher, which we followed and built. We were supposed to take care of the coding aspect of it. So are you saying you don’t see anything wrong with the code?

There is nothing wrong with the logic of the code. I was pointing out that you are giving it a power of 40 out of a possible 127, and that it might not be enough with how the robot is built (that I haven’t seen).

I will give that a shot once I get access to my robot again. Thanks for the quick reply and help!

If it is that you can also use rubber bands to help with lifting the arm for less stress on the motors.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.