A timer in a function

Use 'static' variable to initialize and preserve its value through separate function calls.

#define PinLed  21

bool xBlinkOn;

void Test();

void setup() {
  Serial.begin (115200);
  pinMode(PinLed, OUTPUT | INPUT);
  xBlinkOn = digitalRead(PinLed); // or 0 or 1
}

void loop() {
  Test(millis(), &xBlinkOn);

  digitalWrite(PinLed, xBlinkOn);
}

void Test(unsigned long time , bool* xOutput){
  static unsigned long lastTimeBlink = 0;

  if ( time - lastTimeBlink >= 500) 
  {
    *xOutput = !*xOutput; 
    Serial.println (*xOutput);
    lastTimeBlink = time;
  }
} //Test