switch light with one mousebutton

I want swith light with one mouse button

if I turn on light

the light must turn off automatic after 0.5 second

I’m stuck second place (turn off automatic after 0.5 second)

how can I do this

Coroutine

void Update(){
    if(input.GetMouseButtonUp(0)){
        StartCoroutine(TurnOnLight());
    }
}

IEnumerator TurnOnLight () {
    // turn light on
    yield return new WaitForSeconds(0.5f);
    // turn light off
}

thanks so much but I made with Invoke