ok so im using pros and the competition switch and it works fine and dosent use the code i put in for the aton program when its in driver like it should but when i switch to aton it dosent do anything.
driver code:
#include "main.h"
void operatorControl() {
// Declare inital values.
//Intial Movement Values.
int Z1 = 0;
int Y1 = 0;
int X1 = 0;
int threshold = 7; //Declare Deadzone Limit to zero out all motors if not above.
// Inital Debugging Values.
int debugCtr = 0;
// Motor Port Values.
int frontright = 3;
int backright = 9;
int frontleft = 2;
int backleft = 8;
while(1){/*Loop Forever*/
//Declare Joysticks.
int leftStickUp = joystickGetAnalog(1, 4);
int leftStickLeft = joystickGetAnalog(1, 3);
int rightStickLeft = joystickGetAnalog(1, 1);
//Create "deadzone" for Y1/Ch3, Left Joystick Up and Down.
if(abs(leftStickUp) > threshold){
Y1 = leftStickUp; // If leftStickUp is above +/- 7 then Y1 = Joystick leftStickUp (position)
}else{
Y1 = 0;//If Joystick leftStickUp is below +/- 7 then Y1 = 0
}
//Create "deadzone" for X1/Ch4, Left Joystik Left and Right.
if(abs(leftStickLeft) > threshold){
X1 = leftStickLeft; //If Joystick leftstickLeft is above +/- 7 then X1 = Joystick leftStickLeft (position)
}else{
X1 = 0;//If Joystick leftStickLeft is below +/- 7 then X1 = 0
}
//Create "deadzone" for Z1/Ch1, Right Joystick Left and Right.
if(abs(rightStickLeft) > threshold){
Z1 = rightStickLeft;//If Joystick rightStickLeft is above +/- 7 then Z1 = Joystick rightStickLeft (position)
}else{
Z1 = 0;//If Joystick rightStickLeft is below +/- 7 then Z1 = 0
}
//Math Logic for each Motor.
motorSet(frontright, -Y1 + Z1 + X1);
motorSet(backright, Y1 + Z1 + X1);
motorSet(frontleft, -Y1 + Z1 - X1);
motorSet(backleft, Y1 + Z1 - X1);
delay(20);//Required for any working program at the end of the program in milliseconds?
//Debugging Command.
if( debugCtr++ == 5 ) //Display Y1, X1, Z1 Values in PROS Terminal for debugging.
{
debugCtr = 0;
printf("Joystick Drive Values for: %d %d %d\r\n", Y1, X1, Z1 );
}
}
}
aton code:
/** @file auto.c
* @brief File for autonomous code
*
* This file should contain the user autonomous() function and any functions related to it.
*
* Copyright (c) 2011-2014, Purdue University ACM SIG BOTS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Purdue University ACM SIG BOTS nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL PURDUE UNIVERSITY ACM SIG BOTS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Purdue Robotics OS contains FreeRTOS (http://www.freertos.org) whose source code may be
* obtained from http://sourceforge.net/projects/freertos/files/ or on request.
*/
#include "main.h"
// Motor Port Values.
int frontright = 3;
int backright = 9;
int frontleft = 2;
int backleft = 8;
// Create selectSquareCount number to zero on startup
int selectSquareCount = 0;
//Movement fuction.
void move(int Y1, int X1, int Z1,int timeDelay){
//Math Logic for each Motor.
motorSet(frontright, -Y1 + Z1 + X1);
motorSet(backright, Y1 + Z1 + X1);
motorSet(frontleft, -Y1 + Z1 - X1);
motorSet(backleft, Y1 + Z1 - X1);
delay(timeDelay);
}
void autonomous() {
int bumpSquareSelect = 13;
while(true){
// Add one to selectSquareCount
if(digitalRead(bumpSquareSelect) == 1){
selectSquareCount = selectSquareCount + 1;
delay(20);
}
//If selectSquareCount = 0 then set the LED on slot 1-4 (digital) to flash.
if(selectSquareCount == 0){
pinMode(9, 50);
pinMode(10, 50);
pinMode(11, 50);
pinMode(12, 50);
delay(250);
pinMode(9, 0);
pinMode(10, 0);
pinMode(11, 0);
pinMode(12, 0);
}
}
//If selectSquareCount = 1 then set the LED on slot 1 (digital) to on.
if(selectSquareCount == 1){
pinMode(9, 1);
pinMode(10, 0);
pinMode(11, 0);
pinMode(12, 0);
}
//If selectSquareCount = 2 then set the LED on slot 2 (digital) to on.
if(selectSquareCount == 2){
pinMode(9, 0);
pinMode(10, 1);
pinMode(11, 0);
pinMode(12, 0);
}
//If selectSquareCount = 3 then set the LED on slot 3 (digital) to on.
if(selectSquareCount == 3){
pinMode(9, 0);
pinMode(10, 0);
pinMode(11, 1);
pinMode(12, 0);
}
//If selectSquareCount = 4 then set the LED on slot 4 (digital) to on.
if(selectSquareCount == 4){
pinMode(9, 0);
pinMode(10, 0);
pinMode(11, 0);
pinMode(12, 1);
}
// Look at the selectSquareCount Variable if its over five reset it back to zero.
if(selectSquareCount >= 5){
selectSquareCount = 0;
delay(20);
}
//Group Command for starting square one.
if(selectSquareCount == 1){
//Movement Program.
move(127, 0, 0, 325);
move(0, 0, -127, 250);
move(127, 0, 0, 750);
move(-127, -50, 0, 500);
move(127, 0, 0, 500);
move(127, 127, 0, 250);
move(-127, 0, 0, 750);
move(0, 0, -127, 250);
move(127, 0, 0, 250);
delay(20);
//Flash Square one LED to show the end of the program.
pinMode(9, 0);
pinMode(9, 1);
pinMode(9, 0);
pinMode(9, 1);
pinMode(9, 0);
pinMode(9, 1);
pinMode(9, 0);
pinMode(9, 1);
pinMode(9, 0);
pinMode(9, 1);
pinMode(9, 0);
delay(20);
//Reset the selectSquareCount back to zero to choose the next starting square.
selectSquareCount = 0;
delay(20);
}
//Group command for starting in square two.
if(selectSquareCount == 2){
//Movement Program.
move(127, 0, 0, 325);
move(0, 0, 127, 250);
move(127, 0, 0, 750);
move(-127, -50, 0, 500);
move(127, 0, 0, 500);
move(127, 127, 0, 250);
move(-127, 0, 0, 1000);
move(0, 0, -127, 250);
move(127, 0, 0, 250);
delay(20);
//Flash Square two LED to show the end of the program.
pinMode(10, 0);
pinMode(10, 1);
pinMode(10, 0);
pinMode(10, 1);
pinMode(10, 0);
pinMode(10, 1);
pinMode(10, 0);
pinMode(10, 1);
pinMode(10, 0);
pinMode(10, 1);
pinMode(10, 0);
delay(20);
//Reset the selectSquareCount back to zero to choose the next starting square.
selectSquareCount = 0;
delay(20);
}
//Group command for starting in square three.
if(selectSquareCount == 3){
move(0, 127, 0, 325);
move(0, 0, 127, 250);
move(0, 127, 0, 1000);
move(50, 127, 0, 500);
move(0, -127, 0, 500);
move(127, 127, 0, 250);
move(0, -127, 0, 0);
move(0, 0, -127, 250);
move(-127, 0, 0, 250);
delay(20);
//Flash Square two LED to show the end of the program.
pinMode(11, 0);
pinMode(11, 1);
pinMode(11, 0);
pinMode(11, 1);
pinMode(11, 0);
pinMode(11, 1);
pinMode(11, 0);
pinMode(11, 1);
pinMode(11, 0);
pinMode(11, 1);
pinMode(11, 0);
delay(20);
//Reset the selectSquareCount back to zero to choose the next starting square.
selectSquareCount = 0;
delay(20);
}
//Group command for starting in square four.
if(selectSquareCount == 4){
move(0, 127, 0, 325);
move(0, 0, -127, 250);
move(0, 127, 0, 1000);
move(50, 127, 0, 500);
move(0, -127, 0, 500);
move(127, 127, 0, 250);
move(0, -127, 0, 0);
move(0, 0, -127, 250);
move(-127, 0, 0, 250);
delay(20);
selectSquareCount = 0;
}
}
can some one tell me what im doing wrong…thanks …