Your mind is probably thinking about too many things. You can also try this trick.
I read about a simple technique in a meditation book (the purpose of this was not falling asleep, but it works for me). Close your eyes and start counting with a special technique to infinity.
The trick is to count one number while breathing in... slowly counting in your head until you are done breathing in and when your breath out immediately switch to the next number. There should basically be no moment where you have time to think about anything else besides the numbers. The switch from i to i+1 must be instant. Because if you are leaving gaps your mind starts wandering again.
If you find out that you got distracted start again at 1. Don't cheat.
Just run this JavaScript code in your head the next time (recognize that there are no calls to mind.thinkAboutSomethingElse()!):
I'll second this. The method I use is to count to five, then return to 1. You can sort of gage where you're at, as you'll catch yourself hitting 6, 10, 12 before returning to one. This is a good sign, just don't get too excited about the fact that you're about to fall asleep...
(Also, recently I had only been awake 8h that "day", but needed to get to sleep "early" in order to get a full 8h of sleep before a client meeting the next morning. So, I made Mac&Cheese with an entire stick of butter (~1500cal + 90g fat). This seemed to slow my heart down and put me out like a light. Though this method has obvious health implications, I'd be lying if I said it didn't work like a charm... that one time.)
I read about a simple technique in a meditation book (the purpose of this was not falling asleep, but it works for me). Close your eyes and start counting with a special technique to infinity.
The trick is to count one number while breathing in... slowly counting in your head until you are done breathing in and when your breath out immediately switch to the next number. There should basically be no moment where you have time to think about anything else besides the numbers. The switch from i to i+1 must be instant. Because if you are leaving gaps your mind starts wandering again.
If you find out that you got distracted start again at 1. Don't cheat.
Just run this JavaScript code in your head the next time (recognize that there are no calls to mind.thinkAboutSomethingElse()!):
___
var i = 1;
while(!body.isSleeping()) {
}___