
PRO
dbeard
USA
Asked
— Edited

Can someone explain how to interface a light sensor (2 wires) to the EzB. I would like the robot to be able to tell light from dark.
Thanks.
If that is the case then a simple circuit connected to the analogue port will work. Similar to a voltage divider, when the resistance of the LDR/light sensor varies so will the voltage that's applied to the signal pin on the analogue port.
You can then use a simple script or ADC control to monitor the port and react accordingly.
A simple LDR circuit could be something like this;
The LDRs resistance range will determine the value of R1.
Note, this was a very quick schematic and I was too lazy to use the correct symbols however the general idea should be obvious.
thanks in advance.
Code:
Where 0 might represent complete darkness and 255 would be bright sun.... Values in between represent varying degrees of brighness
Personally I would have a script with the following set up.
Code:
Then have that start with a ControlCommand in an init script.
The variable $cds would be global (i.e. available to all other scripts and controls in ARC). You can then simply use the variable in other scripts which may need it without needing to worry about getting the light value manually.
thanks