Folks, here's a cool trick to detect light.
Connect an LED - any LED should work, but I chose a phosphor "white" -
between an analog input processor pin and ground. Connect the LED
_anode_ to ground, the reverse of normal LED wiring; no resistor is
necessary. That's the extent of the hardware.
To measure illumination hitting the LED, do this:
call PutPin(BackwardsLEDpin, bxOutputHigh) 'charge the LED
uiLightValue = cuint(RCTime(BackwardsLEDpin, 1) 'discharge the LED
Brighter illumination will produce a smaller value, dimmer larger, but
below some brightness threshold, RCTime will timeout and yield zero.
Using a phosphor white LED makes the device sensitive to UV, since the
LED phosphor will be excited and, in turn, illuminate the LED. It is
moderately UV sensitive, in fact.
This works by treating the LED as a light-dependent capacitor,
charging it to supply voltage and using RCTime to determine how long
it takes to discharge.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Actually, the RCTime technique works on any input pin and it seems to
work very well with a grounded-anode IR photodiode, too.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
> ... photodiode, too.
I see that this technique has been shown before; it was buried in
http://tech.groups.yahoo.com/group/basicx/message/20743 , by
bryanwasherein04.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )