Light sensor with LED display

From StdOut
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

I used this module to control the LED lights in my first apartment.
LSU mounted in the living room.

This module measures the light intensify and shows this on a scale from 0 to 782 on the LED display. By multiplying the shown value with 5, and then divide by 127 you get the light intensity in µW/cm2. The threshold value is shown while it's being adjusted, if the light intensity rises over/or falls below (optional) the output will be activated. The hysteresis is +-25. Only one digit is shown on the LED display at any time, but the speed is so fast that me see it as three stable digits.

Video

This video is also available on YouTube.

LED-Display

Light-sensor-led-display-illustration-3gz734.png

When DP lit:

  1. Showing threshold value
  2. Output active
  3. EEPROM value not yet saved.

I/O

Inputs

  1. PC.0 Light sensor, analog value
  2. PC.1 Threshold up
  3. PC.2 Threshold down
  4. PC.3 Over/under threshold

Calculations

Light intensity

Outputs

  1. PB.0 LED-display digit 1
  2. PB.1 LED-display digit 2
  3. PB.2 LED-display digit 3
  4. PB.3 Output constant
  5. PB.4 Output pulse

LED-Display

  1. PortD.0 LED-display A
  2. PortD.1 LED-display B
  3. PortD.2 LED-display C
  4. PortD.3 LED-display D
  5. PortD.4 LED-display E
  6. PortD.5 LED-display F
  7. PortD.6 LED-display G
  8. PortD.7 LED-display DP

Led-display-segments-and-pin-out-j4611g.jpeg Led-display-binary-values-9q7v3q.png

D-Sub 9-pin

Pin Function Color
1 9-15V + Yellow
2 GND White
3 Output constant Green
4 Output pulse Brown

Source code

Git-alt-brands.svg
Bascom-AVR source is available in a git repository:
https://github.com/thomasjsn/AVR-Light-sensor

Gallery

Schematic drawing

Light-sensor-circuit-pgo0pg.png

Parts list

Qty. Part
1 × AVR ATmega8-16PU, DIL-28, 16 MHz, 23 I/Os
1 × Capacitor, aluminium electrolytic, 10 µF, 25V
2 × Capacitor, aluminium electrolytic, 47 µF, 25V
1 × Capacitor, ceramic, 1 nF, 100V
2 m Control cable, 4-cores, 0.25mm2, 250 V, Ø 4.6mm
1 × D-sub soldering cups, 9 pin male
1 × DIL socket, 28-pin, 7.62mm
1 × Diode, rectifier, 1 A, 400V, 1N4004
1 × Enclosure, plastic (1591 FL), 120x65x40mm, flange
1 × Fuse 5x20 mm, 400 mA, fast-acting
1 × Fuse holder, open, PCB, 5x20mm
1 × Fuse holder, open, PCB, Protective cover
1 × Heatsink, 27.3K/W, 19mm, attachable, TO220
1 × LED display, 3x7-segment, 9.2mm, Green
1 × Light-to-voltage sensor, TSL 250R, 127mV / (μW/cm2)
32 cm2 PCB, stripboard, 100x160mm, 160cm2
11 × Resistor, carbon film, 0.25W, 330 Ω, 5%
6 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
3 × Resistor, carbon film, 0.25W, 10 kΩ, 5%
3 × Spacer, round unthreaded, 3mm, Ø6mm, Delrin
22 × Straight pin header, female, Single row, 2.54mm
22 × Straight pin header, male, Single row, 2.54mm
1 × Switch, toggle, 1-pole, micro, (on)-off-(on)
1 × Switch, toggle, 1-pole, micro, on-on
5 × Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
1 × Voltage regulator +5V, 2 A, L78S05CV