vex speaker and competition…
I’m trying to get our speaker to play when we activate it (button 8 R) … However it stops any use of the controller when we activate the speaker. I’m assuming the autonomous mode will not work either since we can’t drive with the speaker playing at the moment. I’ll attach my code. I’m sure this is a coding issue we are having. Any help?
#pragma config(Motor, port2, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, RightMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, LeftMotor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, ClawMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, ArmMotor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VEX EDR */
/* */
/*---------------------------------------------------------------------------*/
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks
// running between Autonomous and Driver controlled modes. You will need to
// manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
// used by the competition include file, for example, you might want
// to display your team name on the LCD in this function.
// bDisplayCompetitionStatusOnLcd = false;
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
task autonomous()
{
// ..........................................................................
// Insert user code here.
// ..........................................................................
// Remove this function call once you have "real" code.
AutonomousCodePlaceholderForTesting();
}
/*---------------------------------------------------------------------------*/
/* */
/* User Control Task */
/* */
/* This task is used to control your robot during the user control phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
task usercontrol()
{
// User control code here, inside the loop
while (true)
{
//Right side of the robot is controlled by the right joystick, Y-axis
motor[RightMotor] = vexRT[Ch2];
motor[RightMotor] = vexRT[Ch2];
//Left side of the robot is controlled by the left joystick, Y-axis
motor[LeftMotor] = vexRT[Ch3];
motor[LeftMotor] = vexRT[Ch3];
//grabber Control
if(vexRT[Btn6D] == 1)
{
motor[ClawMotor] = -40;
}
else if(vexRT[Btn6U] == 1)
{
motor[ClawMotor] = 40;
}
else
{
motor[ClawMotor] = 0;
}
//arm Control
if(vexRT[Btn5D] == 1)
{
motor[ArmMotor] = -40;
}
else if(vexRT[Btn5U] == 1)
{
motor[ArmMotor] = 40;
}
else
{
motor[ArmMotor] = 0;
}
if(vexRT[btn8R] == 1)
{
playSoundFile("1.wav");
wait(10);
clearSounds();
}
}
}