I’ve posted several times about different counting techniques that I’ve used to help calm and ground myself (counting backwards, counting 100 breaths). It sounds like such a simple thing, but it is surprisingly effective.
Counting is one of those things that we naturally learn when we are very young, and because it’s so familiar to us, we can do it with ease as adults.

This ease comes in handy when our Monkey Mind is jumping around like mad, stewing over what has happened or fearing for what is to come. Counting gives it something to do so that its attention is drawn away from anxious thoughts.
In particular, I’ve found this to be useful at night when falling back to sleep has been hindered by that incessant buzz of thinking that won’t go away.
The technique that I’ve used over the last few weeks weaves a counting pattern like this:
Become aware of your body lying in bed. Try to soften the most obvious places of tension (for me, neck and shoulders) and turn your attention to your breath.
Begin by focusing on your inhales of your breaths and counting them, up to ten. Then, switch your focus to your exhales, counting each one up to ten. And again, switch back to focusing on the inhales, continuing this way
The combination of counting up to ten and focusing on either the inhales or exhales provides enough of a distraction from your thoughts, but requires some gentle attention to keep on track. The switching of focus invites your mind to return to the breath.

I’ve found ten to be a very good number; however, five would also work. Whatever you prefer. This might require experimentation to see what is best for you. For example, counting to two might work better for some people during waking hours when there is naturally more stimulation around.
As you establish a pattern with your breath, extend your exhales regardless of where your focus is. This helps slow both your breath and heartrate.
Again, this technique works because counting to ten is simple and unstimulating, allowing the mind to lull itself into a calmer state. When I find myself missing ten and instead counting into the teens without switching my inhale-exhale focus, I know that I’m beginning to drift off. I gently stay with it, but sleep is nearby.