Friday, 12 August 2011


The circuit above implements a light switch which is activated by darkness and movement, using an LDR and a PIR sensor respectively. It draws its power from the voltage it's switching, using a 7805 voltage regulator (on the left). A manual override switch is also provided.

The sketch below implements the brains of this circuit. Highlights are:
  • It smooths the light reading using an array of samples to prevent accidental triggering.
  • Hysteresis also helps with this, a light reading below the light threshold is definitely daylight, while one above the dark threshold is definitely night-time.
  • The light level is tunable using a potentiometer, when it's between the light and dark thresholds, an LED is lit indicating dusk.
  • Another LED is lit, using the signal from the PIR, when motion is detected. This is useful when positioning the box in daylight!
  • A manual override is provided to turn on the light for half an hour when it's daytime, and turn it off for 15s at night-time. (The latter allows the light to be turned off and the operator time to get out of the way.)
Several iterations were required to get the switching behaviour just right for the way it was to be used (in a kitchen). Had it been implemented using discrete hardware, it would not have been so easy to make these changes.

No comments:

Post a Comment