Ok after my initial short lived victory i have finally sussed this out.
The problem is with the lid magnets. Run a very weak magnet alongside the left hand side of the keys at the lower point of the fn button is located the sensor this instantly sends the mac to sleep/wake.
Image
Seriously this is working for me at no expense..... other macbooks the sensor could be located on the right, it's just a matter of locating it...
No more flickering then black and opening and closing until it stays on.......
Late 2009 Macbook 13" White
Model A1181 - Located on the base of your mac
Thanks for this, because that is EXACTLY the problem.
I have MacBook Pro, early 2011 model. The sensor is located on the RIGHT hand side by the right arrow. I have been searching for a while as to why this was happening. Saw that people had mentioned that magnets might be a problem. I wear a magnetic bracelet on my right hand. I put it up to the sensor, and the screen went black instantaneously. DUH!