Surely you have noticed that if you stop using your device, it will automatically turn off the screen and hangs -if appropriate- without you having to do anything. This feature is not new at all, it has been around for many years, but it is really useful. And if you think it takes too long or too little time to do it, don't worry because there is a way to change how long does it take from the device settings.
This function of the Android operating system is focused on save battery and to improve security. It allows the screen not to consume energy unnecessarily, when we do not use the device, and also that if it is within reach of someone, they cannot take advantage of the fact that it is in disuse to 'gossip'. And although it comes with a time configured by default, it may be too short or too long, depending on how we use our smartphone.
How to change how long it takes for your Android screen to turn itself off
Access the native application of Settings and then scroll to the section Screen. Here, among other configuration sections, you will find one with the text 'Timeout to suspend screen'. This is, effectively, the one that determines how long it takes from when we stop using the device until, automatically, the panel is turned off. And we can choose between 15 seconds, 30 seconds, and intervals of 1, 2, 5, 10 and 30 minutes depending on what we prefer.

By default, the Android operating system applies the security lock as soon as the screen is suspended. This means that if we have 15 seconds configured, the lock by password, PIN or biometric hardware will be applied in 15 seconds. But if we have configured in this section that the screen turns off after half an hour, that will be the time it also takes for the device to be blocked with our security system configured.
Therefore, as we mentioned at the beginning, for reasons of autonomy and security, you have to think twice before changing the display settings in this regard. We may notice that the battery lasts a little less time at the end of the day, or we may have problems because someone has reach to our device and it takes too long to apply the lock, for example, with a fingerprint. However, we can change this setting as many times as we want by following exactly the same procedure on our smartphone.
How to keep the screen always on
We may not care about the battery or how long the screen stays on, or it may be that for a work issue we need to always have it active. To do this, without having to touch the default settings of the terminal, we can use an app that allows us to automate this process in a simple way.
One of the most up-to-date is Caffeine, which can be used as a quick adjustment on mobiles with Android Nougat or higher. After installing it you will notice that, surprise, it does not appear in the application drawer. This is because it only works as a quick setting, allowing you to keep the screen on more easily.

To be able to use it, you need to add your quick setting first, displaying the notification panel and editing it on the pencil icon. Next, put on the Caffeine quick setting to have it more accessible, whose icon is a cup of coffee. The quick setting by itself does nothing, but you must activate it yourself. First, display the notification panel and, in the quick settings, tap on the Caffeine icon to activate it. The default mode will keep the screen active for a minute, but tapping on this text will alternate between different settings, until finally the infinity symbol appears.