LED control unit v1.0
From uCtrl.net
LED control unit, 4 digital channels, driven by AVR ATTiny2313.
Contents |
Information
A build-in voltage regulator for 5V allows a input voltage of 9 to 24V. The used is used for digital control of four channels, every channel with a dual color LED (red/green) and a push button. The LEDs show the status of the output, they lit up when a button is pushed and turns off after 10 seconds. By pushing the buttons the outputs can be toggled. The module can receive a external signal that turns off all outputs. Max load is 0.5 A (about 25 LEDs). It's possible to power anything running on 5V with this controller, like relays.
I/O
Inputs
- PA.0 Push button 1
- PA.1 Push button 2
- PD.0 Push button 3
- PD.1 Push button 4
- PD.2 Lights out, from LCU
Outputs
Status LED
- PB.0 LED 1 green
- PB.1 LED 1 red
- PB.2 LED 2 green
- PB.3 LED 2 red
- PB.4 LED 3 green
- PB.5 LED 3 red
- PB.6 LED 4 green
- PB.7 LED 4 red
LED light outputs
D-Sub 9-pin
- LED lighting 1
- LED lighting 2
- LED lighting 3
- LED lighting 4
- Lights out -12V, from LCU
- Lights out +12V, from LCU
- -5V out
- +5V out
Wires
- Yellow
- Green
- Blue
- Purple
- Red
- Brown
- White
- Black
Parts list
| Quantity | Supplier | Part number | Description |
| 1 | Elfa | 73-646-56 | AVR-RISC, ATtiny2313-20PI |
| 1 | Elfa | 50-197-32 | Plastic Enclosure (1591 FL), 120x65x40mm fixed install. |
| 1 | Elfa | 50-194-27 | Plastic Enclosure (1591), 112x62x31mm |
| 1 | Elfa | 44-093-55 | D-Sub plastic hood, 9-pin, black |
| 1 | Elfa | 44-055-51 | D-Sub soldering cups, 9 pin male |
| 1 | Elfa | 44-055-02 | D-Sub soldering cups, 9 pin female |
| 1 | Elfa | 48-161-53 | DIL socket, 20-pin, 7,62mm |
| 1 | Elfa | 48-161-04 | DIL socket, 6-pin, 7,62mm |
| 1 | Elfa | 70-003-91 | Rectifier diode, 1A 400V, 1N4004 |
| 1 | Elfa | 75-646-77 | Heat conducting film for heatsink, Adhesive, TO220 |
| 1 | Elfa | 75-637-78 | Heatsink 6C/W at 10 W, 37,5mm 49g |
| 2 | Elfa | 48-375-06 | Terminal block, PCB, screw, 5mm 2-pin |
| 9 | Elfa | 48-356-90 | Terminal block, screw, 2,5 mm |
| 1 | Elfa | 67-008-01 | Aluminium electrolytic capacitor, 10uF 25V |
| 2 | Elfa | 67-008-68 | Aluminium electrolytic capacitor, 47uF 25V |
| 1 | Elfa | 65-851-94 | Ceramic Disc Capacitor, 1 nF 100V |
| 4 | Elfa | 75-007-13 | LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30° |
| 4 | Elfa | 75-031-96 | LED holder 5mm, RTC51, black plastic |
| 3 | Elfa | 55-264-88 | Stranded Wire, 0.22mm2, 7x0,20mm 50 V grey |
| 3 | Elfa | 55-264-47 | Multiple contact strip, Flat Cable, 7x0,20mm 50 V yellow |
| 1 | Elfa | 55-264-21 | Stranded Wire, 0.22mm2, 7x0,20mm 50 V red |
| 1 | Elfa | 55-264-05 | Stranded Wire, 0.22mm2, 7x0,20mm 50 V black |
| 1 | Elfa | 60-722-84 | Metal film resistor 1% 0,6W, 1 K |
| 5 | Elfa | 60-106-15 | Carbon film resistor 5% 1/4W, 10 K |
| 13 | Elfa | 60-104-33 | Carbon film resistor 5% 1/4W, 330 Ohm |
| 5 | Elfa | 60-105-73 | Carbon film resistor 5% 1/4W, 4,7 K |
| 1 | Elfa | 75-355-94 | Optocoupler DIL-6, CNY17F-3 |
| 13 | Elfa | 43-708-05 | Socket connector 2,54, 1×36, female |
| 13 | Elfa | 43-702-19 | Straight pin header 2,54, 1×36, PCB |
| 1 | Elfa | 33-167-26 | Fuse 5x20 mm, 500 mA, quick-acting |
| 1 | Elfa | 33-150-17 | Open fuse holder, PCB, 5x20mm |
| 1 | Elfa | 33-150-25 | Open fuse holder, PCB, Protective cover |
| 4 | Elfa | 48-858-02 | Skrew, wood, recessed, 3x12mm, + |
| 1 | AUX-01 | Voltage regulator +5V, 1.0A | |
| 1 | Elfa | 42-051-18 | Power Jack, panel, 2,1mm |
| 4 | Elfa | 71-049-87 | Transistor BC337-25, NPN, 45V 0.5A 0.8W |
| 4 | Elfa | 35-084-39 | Push-button Switch, 1-pole, 1A, 50VAC, on-(off) |
Images
PCB complete |
|||
PCB complete |
Box complete with PCB |
||
Relay box for lamp |
|||
Connector 5V for LEDs |
Schematic drawing
Resources
Source code
The program is written in basic, using Bascom-AVR.
'-------------------------------------------------------------- ' Thomas Jensen '-------------------------------------------------------------- ' file: AVR_LED_CONTROL_DIGITAL_4CH_v.1.0 ' date: 17/02/2007 '-------------------------------------------------------------- $regfile = "attiny2313.dat" $crystal = 8000000 Config Watchdog = 1024 Config Portb = Output Config Porta.0 = Input Config Porta.1 = Input Config Portd.0 = Input Config Portd.1 = Input Config Portd.2 = Input Config Portd.3 = Output Config Portd.4 = Output Config Portd.5 = Output Config Portd.6 = Output Dim A As Byte , Ledtimer As Integer Dim Bryter1 As Bit , Bryter2 As Bit , Bryter3 As Bit , Bryter4 As Bit Ledtimer = 100 Bryter1 = 0 Bryter2 = 0 Bryter3 = 0 Bryter4 = 0 Portb = 0 Portd.3 = 0 Portd.4 = 0 Portd.5 = 0 Portd.6 = 0 'Boot sequence For A = 0 To 7 Portb.a = Not Portb.a 'all LEDs on Waitms 250 Next A For A = 0 To 7 Portb.a = Not Portb.a 'all LEDs off Waitms 250 Next A Waitms 1000 Start Watchdog Main: 'start loop 'Change status If Pina.0 = 1 And Bryter1 = 0 Then 'push button 1 Bryter1 = 1 Portd.3 = Not Portd.3 Ledtimer = 100 End If If Pina.1 = 1 And Bryter2 = 0 Then 'push button 2 Bryter2 = 1 Portd.4 = Not Portd.4 Ledtimer = 100 End If If Pind.0 = 1 And Bryter3 = 0 Then 'push button 3 Bryter3 = 1 Portd.5 = Not Portd.5 Ledtimer = 100 End If If Pind.1 = 1 And Bryter4 = 0 Then 'push button 4 Bryter4 = 1 Portd.6 = Not Portd.6 Ledtimer = 100 End If 'Reset button timers If Pina.0 = 0 Then Bryter1 = 0 'push button 1 If Pina.1 = 0 Then Bryter2 = 0 'push button 2 If Pind.0 = 0 Then Bryter3 = 0 'push button 3 If Pind.1 = 0 Then Bryter4 = 0 'push button 4 'LEDs If Ledtimer > 0 Then Decr Ledtimer Portb.0 = Portd.3 'ch 1 LED green Portb.1 = Not Portd.3 'ch 1 LED red Portb.2 = Portd.4 'ch 2 LED green Portb.3 = Not Portd.4 'ch 2 LED red Portb.4 = Portd.5 'ch 3 LED green Portb.5 = Not Portd.5 'ch 3 LED red Portb.6 = Portd.6 'ch 4 LED green Portb.7 = Not Portd.6 'ch 4 LED red End If If Ledtimer = 0 Then Portb = 0 'all LEDs off End If 'Lights out If Pind.2 = 0 Then Ledtimer = 100 Portd.3 = 0 Portd.4 = 0 Portd.5 = 0 Portd.6 = 0 End If Reset Watchdog Waitms 100 Goto Main 'restart loop End