Get joystick digital... Help! Easy C

Hey guys I need help. I’m a novice programmer as you can tell and am using easyC. In my program I have it set up so if I press a button on the joystick is sends a value (1) to a variable. I then have an if statement saying if this variable == 1 then proceed. However whenever I press the button sending the value it seems like the variable stays locked to 1 and it won’t go back to 0 like a normal joystick to digital. I need to know how to get the joystick to send a value of 0 when it isn’t pressed. If there is another way to get a value to a variable via joystick please help me.

It looks kinda like this

int | btn

while (1)
(
btn = GetJoystickDigital (1, 6, 2) \ (sorry no forward slashes) It stays locked on 1 after this.

if (btn == 1)
(
)
)

perhaps post a screen grab of the code, I don’t see anything obvious. You said “It looks kinda like this” so perhaps it not exactly as you wrote.

I’m not familiar with EasyC, so maybe I shouldn’t post this, but would it help if it were written something like this?



   while ( 1 ) 
        {
        if ( GetJoystickDigital(1, 6, 2 ) == 1) 
            {
            //Do something...
            }
        else if ( GetJoystickDigital( 1, 6, 2) == 0 )
            {
            //Do something else...
            }
        Wait ( 50 ) ;
        }

Get joystick digital returns as there or not there. in your if statement, it should be

if (btn)
{
do something…
}

if you look at a potentiometer block, you will notice that it returns as a type of variable, but a ‘get joystick digital’ block returns as nothing. for your variable type in the define variables part of your program, you should use “char”

Hope this helps,
Nxtmonkeys

That’s the same thing as the OP wrote. “there” equates to “true” which equates (usually) to “1”.