const int minX = 3000;
const int maxX = 15000;
bool isAction = false;
void loop()
{
int x = GetX();
if (x >= maxX && !isAction)
{
isAction = true;
// some code . . .
}
else if (x <= minX && isAction)
{
isAction = false;
}
delay(100);
}