View unanswered posts | View active topics It is currently Tue Aug 04, 2020 9:43 pm

Reply to topic  [ 2 posts ] 
Please help me with my teleop code! 
Author Message

Joined: Sun Oct 12, 2014 3:29 pm
Posts: 4
Location: Western Center Academy
Post Please help me with my teleop code!
So, I am making a teleop program for our FTC Tetrix robot and my code is currently not working, so if someone would be so kind as to help me fix my code that would be great.
Well here it is:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     RightDrive,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     empty,         tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     LeftDrive,     tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     empty,         tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
         if(joy1Btn(joy1_y1) == -128)
                   motor(LeftDrive) = 100;
       else if(joy1Btn(joy1_y2) == -128)
                   motor(RightDrive) = 100;
                motor(LeftDrive) = 0;
                motor(RightDrive) = 0;

So I go in to the Samantha Field Control program, connect to the robot with samantha, and start the match and nothing happens. All the motors are connected, all the wires are in tight, I set the teleop program on the NXT to this program, and thats all I can think of, so thank you in advance.

We are the NANOSLUGS! FTC Team number 5755!

Sun Oct 12, 2014 3:53 pm
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Please help me with my teleop code!
I'm amazed this even compiles. But, ROBOTC seems to allow some funky things when it comes to the joysticks. Anyhow, if you're going for analog control, what you need is something like this:

motor[LeftDrive] = joystick.joy1_y1;
motor[RightDrive] = joystick.joy1_y2;

If you want to include a dead band (since the controller sticks usually don't return exactly to 0), you would need something like:
const int DEAD_ZONE = [insert value you want here];
if (abs(joystick.joy1_y1) > DEAD_ZONE)
  motor[DriveLeft] = joystick.joy1_y1;
  motor[DriveLeft] = 0;

And then use the same type setup for your right motor.

FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at

Sun Oct 12, 2014 9:37 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.