Weird analog readings

Don't do this, 12V will definitely fry your Arduino if too much light falls on the photodiode. One fix is to wire a Schottky diode between x and 5V to clamp the photodiode output to 5.4V and protect the pin's protection diode, but you might be better just increasing the resistor value for higher sensitivity?