|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Using Integer variables
Can anyone show me an example of how to setup an integer variable in the BuiltinDefaultCode example?
|
|
#2
|
|||||
|
|||||
|
Re: Using Integer variables
In general, it's as easy as saying
Code:
int varname; What do you want to use the variable for? |
|
#3
|
||||
|
||||
|
Re: Using Integer variables
yes, where to put the variable seems to be our problem. we want to use the variable to keep track of the state of one of our joystick buttons in teleop mode.
int x; //Now later in the program during teleop routines if (rightStick->GetRawButton(2)) { if x = 1 { x=0; } else { x=1; } x could then be examined to determine the speed of our motors. |
|
#4
|
||||
|
||||
|
Re: Using Integer variables
Where to put x is called scope. If you want x available throughout teleop mode (but you don't need it anywhere else), you can put it directly after OperatorControl(){
You may want to do some more research into scope though. It is an important concept to master. |
|
#5
|
||||
|
||||
|
Re: Using Integer variables
Quote:
Code:
if (x == 1) { ...
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying a 16 bit integer on PIC 16F877? | Ian Curtis | Programming | 4 | 20-06-2008 15:42 |
| integer print not making any sense. | windell747 | Programming | 2 | 14-02-2008 23:32 |
| integer division | ImmortalAres | Programming | 5 | 11-07-2005 21:19 |
| Integer Number | powercat | Programming | 2 | 18-02-2003 11:26 |