Reoff's

I am in Vex Open Robotics and we are required to have a reoff that connects to brain and to the led light strips. When we connect to autonomus we have to press a button to start it and when we try to do driver mode we have to press the button for auton to go again then we can drive. Is there a way that we don't have to press the button and when these light sensors change and that our autonomus automatically goes same with driving?

This is our program:

#pragma config(Sensor, in1, LightS, sensorReflection)
#pragma config(Motor, port3, LeftBack, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, RightFront, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, RightBack, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port6, OutsideArm, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port7, InsideArm, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port8, LeftFront, tmotorVex393_MC29, openLoop, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
while(vexRT[Btn8D] == 0)
{
}
motor[LeftFront] = -127;
motor[LeftBack] = -127;
motor[RightFront] = -127;
motor[RightBack] = -127;
wait1Msec(1200);
motor[LeftFront] = 0;
motor[LeftBack] = 0;
motor[RightFront] = 0;
motor[RightBack] = 0;
wait1Msec(500);
motor[LeftFront] = 127;
motor[LeftBack] = 127;
motor[RightFront] = 127;
motor[RightBack] = 127;
wait1Msec(1200);
motor[LeftFront] = 0;
motor[LeftBack] = 0;
motor[RightFront] = 0;
motor[RightBack] = 0;


while(1==1)
{
//Driving Motor Control
motor[port8] = vexRT[Ch3];
motor[LeftBack] = vexRT[Ch3];
motor[RightFront] = vexRT[Ch2];
motor[RightBack] = vexRT[Ch2];


//Arm Control
if(vexRT[Btn6U] == 1)
{
motor[OutsideArm] = 127;
motor[InsideArm] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[OutsideArm] = -40;
motor[InsideArm] = -40;
}
else
{
motor[OutsideArm] = 0;
motor[InsideArm] = 0;
}
}
}
You may find people on this forum who are able to help you, but keep in mind, we are focused on C++ here, I don't think this would look any familiar to most people :)
Comments and indentation help (don't forget to use [code][/code] tags).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma config(Sensor, in1, LightS, sensorReflection)
#pragma config(Motor, port3, LeftBack, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, RightFront, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, RightBack, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port6, OutsideArm, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port7, InsideArm, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port8, LeftFront, tmotorVex393_MC29, openLoop, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
  // Wait for Btn8D down
  while (vexRT[Btn8D] == 0) {
  }
  
  // go back
  motor[LeftFront] = -127;
  motor[LeftBack] = -127;
  motor[RightFront] = -127;
  motor[RightBack] = -127;
  wait1Msec(1200);
  
  // stop
  motor[LeftFront] = 0;
  motor[LeftBack] = 0;
  motor[RightFront] = 0;
  motor[RightBack] = 0;
  wait1Msec(500);
  
  // go forward
  motor[LeftFront] = 127;
  motor[LeftBack] = 127;
  motor[RightFront] = 127;
  motor[RightBack] = 127;
  wait1Msec(1200);
  
  // stop
  motor[LeftFront] = 0;
  motor[LeftBack] = 0;
  motor[RightFront] = 0;
  motor[RightBack] = 0;

  // do this forever more...
  while (1 == 1) {
    //Driving Motor Control
    motor[port8] = vexRT[Ch3];          // why port8 and not LeftFront
    motor[LeftBack] = vexRT[Ch3];       // what is vexRT[Ch3] ?
    motor[RightFront] = vexRT[Ch2];     // is it one of the buttons?
    motor[RightBack] = vexRT[Ch2];

    //Arm Control
    if (vexRT[Btn6U] == 1) {
      motor[OutsideArm] = 127;
      motor[InsideArm] = 127;
    } else if (vexRT[Btn6D] == 1) {
      motor[OutsideArm] = -40;
      motor[InsideArm] = -40;
    } else {
      // are Btn6U and Btn6D the same physical button?
      // if so, you're never executing this code!
      motor[OutsideArm] = 0;
      motor[InsideArm] = 0;
    }
  }
}


If you want to get rid of buttons, perhaps you need to be paying attention to your optical sensor.
#pragma config(Sensor, in1, LightS, sensorReflection)

Topic archived. No new replies allowed.