I am doing the Elevator project for POE. Whenever I start the program the motor starts automatically, I am just confused as to how to make each button work independently.
Try using an else statement and see if it fixes the problem. That will create a base state of resting. It could also be as simple as you need to cycle your cortex power completely off and on or robotc itself.
You shouldn’t have the extra { between the if and the while. Brackets should only begin and end each of your conditional statements (if&while in this case), not go around them…
I could try to make a sample program for you
And yes, Natural Language is ROBOTC…
Just tell me all the ports and I would write one for you, and what button you want to press to activate that motor…
@DeadMagicSocial Here’s my finished product, you should’ve added ‘else if’ and ‘else’. Also including to stop the motors when nothing is pressed… It should work (Plus you had too many ‘}’ in the code);
task main() //Start task
{
while ( 1 == 1) //While Remote is connected
{
if(SensorValue[dgtl2]==1) //While Dgtl2 is active
{
motor[Elevator]=25; //Motor Elevator at 25 power
wait1000msec(6.1); //Wait 6.1 seconds
motor[Elevator]=0; //Motor elevator at 0 power
}
else if(SensorValue[dgtl1]==1) //While Dgtl1 is active
{
motor[Elevator]=25; //Motor Elevator at 25 power
wait1000msec(12.2); //Wait 12.2 seconds
motor[Elevator]=0; //Motor Elevator at 0 power
}
else if(SensorValue[dgtl4]==1) //While Dgtl4 is active
{
motor[Elevator]=-25; //Motor Elevator at -25 power
wait1000msec(6.4); //Wait 6.4 seconds
motor[Elevator]=0; //Motor Elevator at 0 power
}
else if(SensorValue[dgtl3]==1) //While Dgtl3 is active
{
motor[Elevator]=25; //Motor Elevator at 25 power
wait1000msec(6.1); //Wait 6.1 Seconds
motor[Elevator]=0; //Motor Elevator at 0 power
}
else if(SensorValue[dgtl6]==1) //While Dgtl6 is active
{
motor[Elevator]=-25; //Motor Elevator at -25 power
wait1000msec(14.2); //Wait 14.2 seconds
motor[Elevator]=0; Motor Elevator at 0 power
}
else if(SensorValue[dgtl5]==1) //While Dgtl5 is active
{
motor[Elevator]=-25; //Motor Elevator at -25 power
wait1000msec(6.1); //Wait 6.1 Seconds
motor[Elevator]=0; //Motor Elevator at 0 power
}
else
{
motor[Elevator]=0; //Motor Elevator at 0 power
}
}
}
Also, there might be a thing about the ports evaluating to 1 if not pressed and 0 if pressed, I’m not sure. Sorry about the lack of comments, but Vex Forum’s limited line length on iPhone makes them come out weirdly.