|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
I am trying to assign buttons to control a Tetrix DC motor when ever i assign 2 functions to control the same motor say one button forward and one backward the motor coughs and jumps and vibrates moving spastically. I attached the code below, how could i solve this problem?
if(joy2Btn(2) ) { motor[motorF] = 100; } else { motor[motorF] = 0; } if(joy2Btn(1) ) { motor[motorF] = -100; } else { motor[motorF] = 0; } |
|
#2
|
|||||
|
|||||
|
Re: [FTC]: Buttons RobotC
Let's break this down step by step:
Quote:
Quote:
The problem is not with the if (true) conditions, it's the else conditions that are conflicting with each other. If Button 1 is pressed, then button might or might be pressed, so motorF shouldn't go (the else conditions). Likewise for Button 2. A better way to right the code is: Code:
if (joy2Btn(1))
{
motor[motorF] = -100;
}
else if (joy2Btn(2))
{
motor[motorF] = 100;
}
else
{
motor[motorF] = 0;
}
Good luck! |
|
#3
|
|||||
|
|||||
|
Re: [FTC]: Buttons RobotC
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [FTC]: Programming Clarification [RobotC] | basicxman | FIRST Tech Challenge | 3 | 11-02-2009 20:21 |
| [FTC]: RobotC and NXT-G (The two programming languages) | craig_yates | FIRST Tech Challenge | 1 | 30-01-2009 21:47 |
| [FTC]: [FTC]: RobotC Template Problem (causing an FMS issue) and Potential Servo Prob | PackersFan | FIRST Tech Challenge | 11 | 26-01-2009 21:25 |
| [FTC]: RobotC Template | gdo | FIRST Tech Challenge | 14 | 10-11-2008 06:26 |