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

Teleop motor on button not working
http://robotc.net/forums/viewtopic.php?f=52&t=4939
Page 1 of 1

Author:  t70rulz [ Tue Oct 02, 2012 11:54 am ]
Post subject:  Teleop motor on button not working

I need help with this program. The error is with else, it says its invalid.

#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, bucket, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_2, ball, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_1, left, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_2, right, tmotorTetrix, openLoop, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tele-Operation Mode Code Template
//
// This file contains a template for simplified creation of an tele-op program for an FTC
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// initializeRobot
//
// Prior to the start of tele-op mode, you may want to perform some initialization on your robot
// and the variables within your program.
//
// In most cases, you may not have to add any code to this function and it will remain "empty".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

void initializeRobot()
{
// Place code here to sinitialize servos to starting positions.
// Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.

return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main Task
//
// The following is the main code for the tele-op robot operation. Customize as appropriate for
// your specific robot.
//
// Game controller / joystick information is sent periodically (about every 50 milliseconds) from
// the FMS (Field Management System) to the robot. Most tele-op programs will follow the following
// logic:
// 1. Loop forever repeating the following actions:
// 2. Get the latest game controller / joystick settings that have been received from the PC.
// 3. Perform appropriate actions based on the joystick + buttons settings. This is usually a
// simple action:
// * Joystick values are usually directly translated into power levels for a motor or
// position of a servo.
// * Buttons are usually used to start/stop a motor or cause a servo to move to a specific
// position.
// 4. Repeat the loop.
//
// Your program needs to continuously loop because you need to continuously respond to changes in
// the game controller settings.
//
// At the end of the tele-op period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase

while (true)
{
getJoystickSettings(joystick);
{
motor[left] = joystick.joy1_y1;
motor[right] = joystick.joy1_y2;
}

{
if(joy1btn(7));
{
motor[ball] = 70;
}
else
{
motor[ball] = 0;
}
}


}
}

Author:  MHTS [ Tue Oct 02, 2012 1:35 pm ]
Post subject:  Re: Teleop motor on button not working

Please put your code in proper indentation and using the "Code" tag when posting code. It makes it a lot easier to spot problems.
Code:
task main()
{
    initializeRobot();

    waitForStart(); // wait for start of tele-op phase

    while (true)
    {
        getJoystickSettings(joystick);
        {
            motor[left] = joystick.joy1_y1;
            motor[right] = joystick.joy1_y2;
        }

        {
            if(joy1btn(7));
            {
                motor[ball] = 70;
            }
            else
            {
                motor[ball] = 0;
            }
        }
    }
}

In your case here, the culprit is:
Code:
            if(joy1btn(7));

You need to remove the ';' at the end of the statement.

Author:  t70rulz [ Thu Jan 03, 2013 4:36 pm ]
Post subject:  Re: Teleop motor on button not working

Ok thank you very much

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