Hello, when i identify the sensors in this:
vex::motor ClawMotor = vex::motor(vex::PORT16);
vex::motor LeftMotor = vex::motor(vex::PORT19);
vex::motor RightMotor = vex::motor(vex::PORT1);
vex::motor Motor1 = vex::motor(vex::PORT4, true);
vex::motor Motor2 = vex::motor(vex::PORT14, true);
vex::controller Controller1 = vex::controller();
line LineSensor1 (Brain.ThreeWirePort.A);
line LineSensor3 (Brain.ThreeWirePort.C);
it won’t let the motors run, do you guys know why?
Please post your complete code (remember to wrap it in [code]...[/code]
tags for formatting!), otherwise it’s nearly impossible to debug code without seeing it.
A more complete description of your problem would probably be helpful as well - could you elaborate more on “won’t let the motors run”?
1 Like
thanks for the formatting tip, what i mean buy “don’t run” I mean that the motors won’t spin, and will sit there and do nothing.
Hmm, declaring sensors should not stop motors from being able to spin.
Please post your complete program and we can try to be of more help.
#include "vex.h"
using namespace vex;
vex::motor ClawMotor = vex::motor(vex::PORT16);
vex::motor LeftMotor = vex::motor(vex::PORT19);
vex::motor RightMotor = vex::motor(vex::PORT1);
vex::motor Motor1 = vex::motor(vex::PORT4, true);
vex::motor Motor2 = vex::motor(vex::PORT14, true);
vex::controller Controller1 = vex::controller();
line LineSensor1 (Brain.ThreeWirePort.A);
line LineSensor2 (Brain.ThreeWirePort.B);
line LineSensor3 (Brain.ThreeWirePort.C);
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
LeftMotor.spin(directionType::fwd, 50, velocityUnits::pct);
RightMotor.spin(directionType::rev, 50, velocityUnits::pct);
task::sleep(2000);
while (LineSensor1.value(pct) < 1000 && LineSensor3.value(pct) < 1000) {
[code]LeftMotor.spin(directionType::fwd, 50, velocityUnits::pct);[/code]
RightMotor.spin(directionType::rev, 50, velocityUnits::pct);
}
}
Deicer
December 21, 2019, 3:27am
#6
#include "vex.h"
using namespace vex;
vex::motor ClawMotor = vex::motor(vex::PORT16);
vex::motor LeftMotor = vex::motor(vex::PORT19);
vex::motor RightMotor = vex::motor(vex::PORT1);
vex::motor Motor1 = vex::motor(vex::PORT4, true);
vex::motor Motor2 = vex::motor(vex::PORT14, true);
vex::controller Controller1 = vex::controller();
line LineSensor1 (Brain.ThreeWirePort.A);
line LineSensor2 (Brain.ThreeWirePort.B);
line LineSensor3 (Brain.ThreeWirePort.C);
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
LeftMotor.spin(directionType::fwd, 50, velocityUnits::pct);
RightMotor.spin(directionType::rev, 50, velocityUnits::pct);
task::sleep(2000);
while (LineSensor1.value(pct) < 1000 && LineSensor3.value(pct) < 1000) {
LeftMotor.spin(directionType::fwd, 50, velocityUnits::pct);
RightMotor.spin(directionType::rev, 50, velocityUnits::pct);
}
}
3 Likes
lol thanks for your help…
Deicer
December 21, 2019, 3:32am
#8
I don’t think it is your code that is the problem. Is the robot working with other code?
1 Like
Where is Brain defined ?
you may be running into the same issue as described in this topic.
If that is being used in a file other than robot-config.cpp, there’s a good chance that there is no Brain.ThreeWirePort.A instance as the order that constructors are called is not guaranteed across files.
either move to the same file as where Brain is constructed or do something like this.
triport ThreeWirePort = vex::triport( vex::PORT22 );
gyro myGyro = vex::gyro(ThreeWirePort.A);
that is, trying to use Brain.ThreeWirePort before it has been created.
5 Likes
I tried that and it still just sits there:c
S0, have you guys ever experienced this problem?
send me the whole project (use export or zip the folder)
2 Likes
system
closed
December 20, 2020, 11:40pm
#14
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.