View unanswered posts | View active topics It is currently Sun Sep 21, 2014 12:38 pm






Reply to topic  [ 2 posts ] 
RobotC triggers 
Author Message
Rookie
User avatar

Joined: Wed Feb 22, 2012 9:04 am
Posts: 20
Location: behind you
Post RobotC triggers
I can't quite figure out how to make the triggers do anything.
My robot is a metal frame with a basic motor set up for tank drive and a rotating arm on top
My code is:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTMotor,  HTMotor)
#pragma config(Hubs,  S2, HTServo,  HTServo,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     leftdrive,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     rightdrive,    tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     armupdown,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     armleftright,  tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     motorH,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorI,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     motorJ,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C4_2,     motorK,        tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S2_C1_1,    claw,                 tServoStandard)
#pragma config(Servo,  srvo_S2_C1_2,    unkwown,              tServoStandard)
#pragma config(Servo,  srvo_S2_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_6,    servo6,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_1,    servo7,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_2,    servo8,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_3,    servo9,               tServoNone)
#pragma config(Servo,  srvo_S2_C2_4,    servo10,              tServoNone)
#pragma config(Servo,  srvo_S2_C2_5,    servo11,              tServoNone)
#pragma config(Servo,  srvo_S2_C2_6,    servo12,              tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/////////////////////////////////////////ROBOT///////////////////////////////////////////
/*///////////////////////////////////////////////////////////////////////////////////////
/Controls                        Description                              othernames    /
/////////////////////////////////////////////////////////////////////////////////////////
/topHat------------used to control the claw being open or closed------------topHat      /
/Button1-----------used to make the arm turn Left---------------------------armleft     /
/Button2-----------used to make the arm go up-------------------------------armup       /
/Button3-----------used to make the arm go down-----------------------------armdown     /
/Button4-----------used to make the arm turn right--------------------------armright    /
/Joystick1---------uesd to make the robot move------------------------------???????     /
/Joystick2---------used to make the robot move------------------------------???????     /
/triggerL1---------???????????????????????????------------------------------???????     /
/triggerL2---------???????????????????????????------------------------------???????     /
/triggerR1---------???????????????????????????------------------------------???????     /
/triggerR2---------???????????????????????????------------------------------???????     /
*////////////////////////////////////////////////////////////////////////////////////////
const int armup = 2;
const int armdown = 3;
const int armleft = 1;
const int armright = 4;
const int threshold = 5;
#include "JoystickDriver.c"

void triggers()
{
  //trigger controls for claw (the claw is a VEX Robotics claw)
}
void handleArm()
{
  //up/down
                                   if (joy1_Btn(armup))
                                   {
                                      motor[armupdown] = 25; //motor that lifts the arm goes up
                                   }
  else if (joy1_Btn(armdown))
  {
    motor[armupdown] = -25; //motor that lifts the arm goes down
  }
  else
  {
    motor[armupdown] = 0; //motor that lifts the arm is stationary
  }
  //left/right
  if (joy1_Btn(armleft))
  {
    motor[armleftright] = 10; //motor that turns the arm moves to the left
  }
  else if (joy1_Btn(armright))
  {
    motor[armleftright] = -10; //motor that turns the arm moves to the right
  }
  else
  {
    motor[armleftright] = 0; //motor that turns the arm is stationary
  }
}
void tankDrive()
{
  //put tank drive code here
  //forward/backward
  //turn left/right
    if(abs(joystick.joy1_y2) > threshold)   // If the right analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[rightdrive] = joystick.joy1_y2;         // Motor rightdrive is assigned a power level equal to the right analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
      motor[rightdrive] = 0;                        // Motor rightdrive is stopped with a power level of 0.
    }


    if(abs(joystick.joy1_y1) > threshold)   // If the left analog stick's Y-axis readings are either above or below the threshold:
    {
      motor[leftdrive] = joystick.joy1_y1;         // Motor leftdrive is assigned a power level equal to the left analog stick's Y-axis reading.
    }
    else                                    // Else if the readings are within the threshold:
    {
      motor[leftdrive] = 0;                        // Motor leftdrive is stopped with a power level of 0.
    }
}

task main()
{
while (true)
{
 getJoystickSettings(joystick);
 handleArm();
 tankDrive();
 triggers();
}
}


Also I keep getting an error in the indented area:
**Error**:Undefined procedure 'joy1_Btn'.

If someone could tell me how to:

1. fix my error
2. program the triggers to work

I would be grateful

~SCOPE

_________________
-------------------
"She laughs at everything you say. Why? Because she has fine teeth."
"Three can keep a secret, if two of them are dead."
"Either write something worth reading or do something worth writing."


Thu Mar 01, 2012 10:32 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: RobotC triggers
The command is joy1Btn(armup), not joy1_Btn(armup). The triggers are accessed by calling joy1Btn(number printed on the trigger)

_________________
sudo rm -rf /


Thu Mar 01, 2012 10:55 am
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.