I just bought my first Arduino board for a small project.
I will be using input from a Photoelectric sensor which either gives current or not (I will put 7805CT to regulate the voltage).
From what I have learnt so far, I should use analogRead to get a value on the pin. Since I'm only interested in whether it is on and off, can I simply use analogReadResolution(1) or is there another, better way for doing this?
Regards
If you're using analogRead() then usually there's a threshold to decide if it's 'on' or 'off'. Like pick a number. If it's greater than that number then it's 'on'. You can also apply hysteresis = don't switch off until it's below some lower number.
You know you can use digitalRead() on analog pins?
Setting the resolution to 1 effectively disables all analog. What if you want to add a real analog sensor later?
What voltages will be present on the pin when the sensor detects light and when it doesn't ?
It sounds like a digital (on/off) device to me and as such you could use digitalRead() to determine the state of the pin.
OK, that make tons of sense 
I was wondering why noone have thought of that brilliant solution before 
Thank you!!