Are you defining the GPIO2 as an output?
check this out: http://www.instructables.com/id/How-to-use-the-ESP8266-01-pins/