user62195: I wanna make some sketch to generate number to represent sensor value, with range from high (900) to low (670), that number decrease with range between 1-10 and with some delay of switching number with range from 5-15 seconds:
    void setup() {
      Serial.begin(9600);
    }

    void number(){
      int sensor = 0;                  //sensor variable
      int a = random(0, 10);           //range subtraction sensor value
      int delay = random(5000, 15000); //range delay switching value
      for(sensor = 900; sensor >= 670; sensor -=a){ //iteration sensor value with range 670-900
        Serial.println(sensor);
        delay(delay);}
    }

    void loop() {
    number();
    }

with output:

900 (delay 7 sec)
894 (delay 3 sec)
988 (delay 5 sec)
979 (delay 9 sec)

The sketch above was work as well, but i still can't using variable "sensor" result after iteration "for" in void loop. 
I hope you can help me, thanks.

user37622: int sensor = 900;                 //variabel sensor

void setup() {
  Serial.begin(9600);
  while (!Serial);
  randomSeed(analogRead(A0));
}

int number() {
  int a = random(0, 10);          //range pengurang nilai sensor
  int d = random(500, 1500); //range delay perubahan nilai
  if (sensor < 670) {
    sensor = 900;
  }
  sensor -= a;
  delay(d);
  return sensor;
}

void loop() {
  int val = number();
  Serial.println(val);
}

I modified the delay for test.
randomSeed ensures different random values at every run
EDIT: a not blocking version which returns the same values for random interval:
int sensor = 900;                 //variabel sensor
unsigned long nextChangeMillis = 0;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  randomSeed(analogRead(A0));
}

int number() {

  if (millis() < nextChangeMillis)
    return sensor;

  int a = random(0, 10);          //range pengurang nilai sensor
  int d = random(500, 1500); //range delay perubahan nilai
  if (sensor < 670) {
    sensor = 900;
  }
  sensor -= a;
  nextChangeMillis += d;
  return sensor;
}

void loop() {
  int val = number();
  Serial.println(val);
}


62195: <p>I wanna make some sketch to generate number to represent sensor value, with range from high (900) to low (670), that number decrease with range between 1-10 and with some delay of switching number with range from 5-15 seconds:</p>

<pre><code>    void setup() {
      Serial.begin(9600);
    }

    void number(){
      int sensor = 0;                  //sensor variable
      int a = random(0, 10);           //range subtraction sensor value
      int delay = random(5000, 15000); //range delay switching value
      for(sensor = 900; sensor &gt;= 670; sensor -=a){ //iteration sensor value with range 670-900
        Serial.println(sensor);
        delay(delay);}
    }

    void loop() {
    number();
    }
</code></pre>

<p>with output:</p>

<ul>
<li>900 (delay 7 sec)</li>
<li>894 (delay 3 sec)</li>
<li>988 (delay 5 sec)</li>
<li>979 (delay 9 sec)</li>
</ul>

<p>The sketch above was work as well, <strong>but i still can't using variable "sensor" result after iteration "for" in void loop</strong>. 
I hope you can help me, thanks.</p>
 37622: <pre><code>int sensor = 900;                 //variabel sensor

void setup() {
  Serial.begin(9600);
  while (!Serial);
  randomSeed(analogRead(A0));
}

int number() {
  int a = random(0, 10);          //range pengurang nilai sensor
  int d = random(500, 1500); //range delay perubahan nilai
  if (sensor &lt; 670) {
    sensor = 900;
  }
  sensor -= a;
  delay(d);
  return sensor;
}

void loop() {
  int val = number();
  Serial.println(val);
}
</code></pre>

<p>I modified the delay for test.</p>

<p><a href="https://www.arduino.cc/reference/en/language/functions/random-numbers/randomseed/" rel="nofollow noreferrer">randomSeed</a> ensures different random values at every run</p>

<p>EDIT: a not blocking version which returns the same values for random interval:</p>

<pre><code>int sensor = 900;                 //variabel sensor
unsigned long nextChangeMillis = 0;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  randomSeed(analogRead(A0));
}

int number() {

  if (millis() &lt; nextChangeMillis)
    return sensor;

  int a = random(0, 10);          //range pengurang nilai sensor
  int d = random(500, 1500); //range delay perubahan nilai
  if (sensor &lt; 670) {
    sensor = 900;
  }
  sensor -= a;
  nextChangeMillis += d;
  return sensor;
}

void loop() {
  int val = number();
  Serial.println(val);
}
</code></pre>
