How to make the screen temporarily go black?

I’m writing a program that is used for attention and perception research, in which a ball starts at a random z coordinate and moves toward the camera. The participant is meant to press the space bar when they think the ball would “hit them”, or reach the camera. I want the screen to go black after a certain amount of time so it reads the participants perception of the speed of the object. I want this to happen anywhere from 1-3 seconds after the program starts. I have code written that restarts the scene after a certain amount of time, so the black screen only needs to occur once. I am new to coding and have no idea how to do this. Can someone help me? Or at least lead me to the documentation necessary?

You can add Panel in Canvas. Name the panel as “BlackScreen”. and in your start method write something like this.

//add
using UnityEngine.UI;

void Start(){
// set color of the panel transparent
GameObject.Find("Canvas/BlackScreen").GetComponent<Image>().color = new Color(0,0,0,0);

//call GoBlack function after random 1-3 seconds 
Invoke("GoBlack",Random.Range(1,3));
}

void GoBlack()
{
// set color of the panel - black
GameObject.Find("Canvas/BlackScreen").GetComponent<Image>().color = new Color(0,0,0,255);
}