My students and I are trying to get a code for using a press button switch to run dragsters for 2-3 seconds. After we push the button, the motors will not turn on. we opened the sample code and modified it, but it will not work. Also, we watched videos and wrote our own code.
one robot the motors turned on, but the robot would not stop until you pushed the button again. I do not know what we are doing wrong. I have been using the vex v 5 coding and modkit. I forgot how to use robot c or I am leaving out a simple command with a punctuation or bracket to start and turn it off. Are limit switches easier than the button? I need serious help. Are there examples of the PLTW dragster or test bed code? I can’t find it.
task main()
{
while(1==1)// this is a loop
{
if(SensorValue(bumpSwitch)==1)// if the bump switch is pressed do the following code
{
{
}
startTask(rightMotor,127);
if(SensorValue(bumpSwitch)==1)// if the bump switch is pressed do the following code
{
{
}
You have an extra set of brackets (I indented them out for clarity), remove those.
startTask(rightMotor,127);
startTask runs a task not a motor. Use something like motor[rightMotor] = 127 instead to move the motor.
{
wait1Msec(4.0);
}
You don’t need the surrounding brackets. wait1Msec takes a time in milliseconds, 4ms is too small for you to notice anything. 1000ms = 1 second, so if you meant to wait 4 seconds, use wait1Msec(4000); instead.
@Battlesquid gave you suggestions, not full working code. Nevertheless, as stated before, please paste your full code here in code tags if you want help. It is nearly impossible to troubleshoot something we can’t see.