ROBOTC.net forums
http://www.robotc.net/forums/

Autonomous code not starting automatically
http://www.robotc.net/forums/viewtopic.php?f=11&t=11738
Page 1 of 1

Author:  Trialwater6 [ Mon Jul 20, 2015 11:43 pm ]
Post subject:  Autonomous code not starting automatically

The code I am currently working on for a competition doesn't start automatically when I put it in the robot. I need help as it only works while it is plugged into the computer.

#pragma config(Sensor, dgtl1, frontl, sensorTouch)
#pragma config(Sensor, dgtl2, frontr, sensorTouch)
#pragma config(Sensor, dgtl3, backl, sensorTouch)
#pragma config(Sensor, dgtl4, backr, sensorTouch)
#pragma config(Sensor, dgtl5, sensorSonar, sensorSONAR_cm)
#pragma config(Motor, port2, frontLeftMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, frontRightMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, backLeftMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port5, backRightMotor, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main ()
{
while(true)
{
wait1Msec (1000);
if (SensorValue(dgtl1) == 1)
{
motor[frontLeftMotor] = 50;
motor[frontRightMotor] = -50;
motor[backLeftMotor] = 50;
motor[backRightMotor] = -50;
wait1Msec (1000);
}
if (SensorValue(sensorSONAR_Ping_cm) < 14)
{
motor[frontLeftMotor] = 55;
motor[frontRightMotor] = 60;
motor[backLeftMotor] = 55;
motor[backRightMotor] = 60;
wait1Msec (1000);
}
else
{
motor[frontLeftMotor] = 60;
motor[frontRightMotor] = 55;
motor[backLeftMotor] = 60;
motor[backRightMotor] = 55;
}

if (SensorValue(sensorSONAR_Ping_cm) > 60)
{
motor[frontLeftMotor] = 80;
motor[frontRightMotor] = 40;
motor[backLeftMotor] = 80;
motor[backRightMotor] = 40;
}
}
}

Author:  Tabor473 [ Tue Jul 21, 2015 12:04 pm ]
Post subject:  Re: Autonomous code not starting automatically

So it appears that your robot is waiting for a joystick to connect before running. You can either use a vexnet joystick or change the settings to not require a joystick before starting.

Robot
Vex Cortex Communication Mode
USB only

This setting means the robot will only search for the computer upon start up rather than constantly so remember to turn the robot off every time you plug it into the computer.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/