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;
}