Two way serial communication with raspberry Pi (radio project)

int upperValue;
int lowerValue;
char ch;
int poti = 0;
int sensorValue;

Some nice global variables...

do
  {  
sensorValue = analogRead(poti);
    int upperValue = sensorValue + 2;
    int lowerValue = sensorValue - 2;

One global variable and two new local variables...

  } while (sensorValue < upperValue && sensorValue > lowerValue);

These names refer to the GLOBAL variables.

OP: You REALLY need to learn about scope.