Welcome

The lightsensor

On to the larger question: What happened with the circuit to turn the device off when it's light? There doesn't seem to be anything left that can sense if it's light or dark. How does that count as 'no functionality lost'?

Admittedly, the amount of parts left to sense the ambient light level is a bit on the meager side. It's all there, though. Let's start at the beginning: it's a known fact that the ATTiny13, as well as the complete AVR-range, is quite good in conserving power: Atmel even has a new line of AVRs which only will consume pico-amperes when sleeping. This is usable: instead of a bunch of transistors cutting power to the AVR to disable it, the AVR can disable itself in software and it won't use up much more power. So, in the original schematic, the lightsensor could have been connected directly to the AVR. The AVR could then put itself to sleep when it detects light and wake itself up periodically to see if the darkness has returned.

But where did the lightsensor go to then? It's actually still in the schematic, disguised as LED2. It's a little-known fact that LEDs can be used as lightsensors as well as light sources. A while ago, it got in the news again with some people using that knowledge to make two devices communicate over only 2 leds. The publication about it is quite readable, and there's a nice recipe for using a LED as both a light source as well as a light sensor right there. Basically, they model the LED as a light-controlled current source in parallel with a parasitic capacitor. By looking at how long it takes for the current source to discharge the capacitor, they are able to tell how much light the LED receives.

While that is a valid way to do it, in practice some leds take quite a long time (up to a few seconds) to discharge their parasitic capacitor. The Tiny13 has an AD-converter, though, so I decided to use that one: now, when the uC wants to know the ambient light level, it'll just power off a led and measure the voltage across its junction. That voltage is somewhat linearly related to the amount of light falling on the LED, so we can use that measurement to decide if the device has to switch on or off.

« Prev 3 Next »


© 2006-2022 Sprite_tm - Contact