Integer not working like I want it to.

I’m trying to make a system for my blinds where when I push a button it goes up and then a different button makes them come down. I’m trying to make a system where when I push “Up” once it won’t let me do anything if it’s pushed a second time, as I don’t want my blinds to keep winding once already up. I’m trying to add 1 to an integer “i” when the blinds go up, and subtract 1 when I bring the blinds back down. I’m using an if statement to make sure the blinds are down if I’m trying to make them go back up and vice versa, but something isn’t working right. When I push the up button again on my remote it seems to override the if statement and just go “Up” again. I’ve attempted to fix it in various ways but I’m not sure what I’m doing wrong. Any help would be much appreciated.

Here’s my code.

#include <IRremote.h>
#include <IRremoteInt.h>

long x;

int receiver = 12;

IRrecv irrecv(receiver);
decode_results results;

void setup()

{
Serial.begin(9600);
x = 0;

Serial.print(“X=”);
Serial.println(x);

{
irrecv.enableIRIn(); //Start receiver

}

}

void loop()
{

if (irrecv.decode(&results)) // have we received an IR signal?

{
switch(results.value)

{

case 0xFF906F: // VOL+ button pressed
{

if(x=0)
{
Serial.println(“Up”);
delay(2000);
(x++);
}

}
break;

case 0xFFE01F: // VOL- button pressed
{

if(x=1)
{
Serial.println(“Down”);
delay(2000);
(x–);
}

}

break;

}

irrecv.resume(); // receive the next value

}

}/* --end main loop – */

 if(x=1)

The problem is here

How do I fix it? Sorry if it's a dumb question, I'm new to arduino and still have a lot to learn.

= sets a variable to a value
== compares two values

It's time for you to read a basic C tutorial I think

You don’t need to brackets round the x++; and x--; statements either.
Plus if it only has two states a Boolean is probably more appropriate.

tryston03:
I don't want my blinds to keep winding once already up.

How will the code know this has happened?

Possibly useful: State Machine Tutorial (and there are others).

dougp:
How will the code know this has happened?

The best way would be a limit switch.

gfvalvo:
The best way would be a limit switch.

And, maybe add a fallback TIMER and spring suspension.