This is one of the most dangerous things to do: driving tired. Some studies have shown that driving tired is as dangerous as driving under the influence of alcohol. So try not to get behind the steering wheel knowing you are tired. You are a danger to yourself and to other road users.
So, what to do in the situations you felt drowsy or tired? The best advice is to assess how much time you have to drive to your destination and how urgent is for you to be there. If the distance was short and you must be there on time, go to a gas station, drink some cold water and coffee. Stay a few minutes. While driving, set the seat in a more uncomfortable position, the air conditioning system to a low temperature and play some music. This should prevent you from falling asleep. But do that only if it was really necessary to arrive somewhere. For any other cases ( you have a lot to drive or you don’t have a required time to arrive ), the best and strongest recommendation I can give is to pull over and have a nap or stop to a hotel. A hour or two should be enough to get some rest. Think about your safety and the safety of the other road users. It is better to arrive later than not at all.