analog inputs vs digital inputs

on my latest post... i uploaded my program... its purpose was too simulate a parking lot... with 2 photoresistors... one to simulate the entrance and the other one to simulate the exit of teh parking lot... my question is if its better to connect the photoresistors in analog or digital...!? and why!?

By “photoresistors” are you referring to an LDR ?

LDR.jpg

yes...

What is it ? How does it work ? Can you measure it with a meter (and a flashlight) ? I'm confused. What is a digital input ? What is an analog input ? How can you tell them apart ?

they are a type of optical resistors that detect light… uv, ir and normal light (ex. flashlight) and can have their sensitivivty range changed by a potentiometer, or variable resistor in other words. thay act as a switch and can activate or deactivate light-sesnsitive detector circuits.

igobyjoey: on my latest post... i uploaded my program... its purpose was too simulate a parking lot... with 2 photoresistors... one to simulate the entrance and the other one to simulate the exit of teh parking lot... my question is if its better to connect the photoresistors in analog or digital...!? and why!?

It's fundamentally an analog component, a resistor that changes it's value depending on light it is exposed to. You normally wire it to another fixed resistor so that you form a voltage divider and then read the junction of the LDR and resistor as a analog input.

Are you sure ? That doesn't sound right.

That isn't what it says here: http://playground.arduino.cc/Learning/PhotoResistor http://hobbybotics.com/tutorials/tutorial-use-a-light-dependent-resistor-ldr-to-measure-light-levels/

(Heck, and all this time I thought it meant Long Distance Relationship.....)

Moderator edit: links corrected

raschemmel: Are you sure ? That doesn't sound right.

That isn't what it says here: http://playground.arduino.cc/Learning/PhotoResistor http://hobbybotics.com/tutorials/tutorial-use-a-light-dependent-resistor-ldr-to-measure-light-levels/

(Heck, and all this time I thought it meant Long Distance Relationship.....)

Who are you addressing? Both links don't bring up anything?

Both links don't bring up anything?

Links corrected.

retrolefty: Who are you addressing?

You two will have to work that one out amongst yourselves.

The way I understand the question, you wish to use the LDR (photoresistor) to detect a car of sorts. You will need to form a voltage divider as stated by retrolefty. If you can get the voltage at the junction to vary between, and including, 1/3 VCC (1.67V) and 2/3 VCC (3.33V), you can use a digital input. If the voltage at the junction <= (less than or equal to) 1.67V, it will register as logic 0 - Low, Off, No, False… If the voltage is >= (greater than or equal to) 3.33V, it will register as logic 1 - High, On, Yes, True… These assume your controller is at 5V. If your controller is 3.3V, adjust the numbers above.

If you find it too difficult to get these voltages (very likely), just use an analogue input. Run a few tests to see what the average values are when a “car” is over the LDR and when it’s not. Then just compare these values in the program itself.