View unanswered posts | View active topics It is currently Thu Aug 22, 2019 11:27 am






Reply to topic  [ 2 posts ] 
Autonomous code not starting automatically 
Author Message
Rookie

Joined: Mon Jul 20, 2015 11:38 pm
Posts: 1
Post 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;
}
}
}


Mon Jul 20, 2015 11:43 pm
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post 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.


Tue Jul 21, 2015 12:04 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.