Having trouble with an if statement

spoocter:
How do i make it like this?

What you're doing is fine. The difference is that a++ modifies a. The way abs() is implemented, it would case a++ to happen twice, which would mean a is one bigger than it should be. The subtraction you're doing is fine, though.

If you really want to know:

void loop(){
  pot = analogRead(A1);

  // Do your stuff here
  int potdiff = pot - pot_before;
  potdiff = abs(potdiff);
  if (potdiff > 2) {
    //do what you want to do here if the difference is bigger than 2 
  }

  pot_before = pot;
}