I tried using digitalRead() but it's stuck to 0.
I just copied the schematic here (Arduino Your Home & Environment: Reflective Optical Sensor with Transistor Output). He used a reflective optical sensor. At first, I connected the sensor directly to the arduino but then I got scared and tried to put a pull up resistor and then I found the the TCRT5000 schematic and copied it anyways.
The shiny thing I mentioned earlier was a metal ruler.
Don't worry I got a mirror and tested it but its still not working.