LED disco light
From uCtrl.net
LED disco light, driven by AVR ATTiny2313.
Contents |
Information
The disco light consists of 33 high intensive LEDs and control circuit. It has four build-in sequences, and the option of cycling trough with a five second delay. If an external controller is plugged in the internal program will stop and the external unit is in control. This makes it possible to connect more units together to form a multi module system. Powered by 12V.
Sequences
- Flashing with fade
- 3 x strobe, pause
- Random pause strobe
- Strobe
I/O
Inputs
- PD.0 : Automatic mode change
- PD.1 : Manual mode change
- PD.2 : External controller: available
- PD.3 : External controller: pulse constant
- PD.4 : External controller: pulse fade
Outputs
D-Sub 9-pin
- 12/13.8 V +
- 5 V +
- GND
- Trigger on/off
- Trigger fade on/off
- Trigger common +
- External controller available (N.O)
- External controller available (N.O)
Parts list
| Quantity | Supplier | Part number | Description |
| 1 | Elfa | 73-646-56 | AVR-RISC, ATtiny2313-20PI |
| 1 | Elfa | 50-195-00 | Plastic Enclosure (1591), 120x80x59mm |
| 1 | Elfa | 44-055-51 | D-Sub soldering cups, 9 pin male |
| 1 | Elfa | 48-161-53 | DIL socket, 20-pin, 7,62mm |
| 2 | Elfa | 48-161-04 | DIL socket, 6-pin, 7,62mm |
| 2 | Elfa | 48-884-18 | Unthreaded round spacer, 3mm, Ø6mm |
| 2 | Elfa | 75-612-36 | Heatsink, 27.3 K/W, 19mm, attachable, TO220 |
| 2 | Elfa | 48-351-04 | Terminal block, pluggable, 3.5 mm, 2-pin skrew female |
| 2 | Elfa | 48-351-53 | Terminal block, pluggable, 3.5 mm, 2-pin vertical male |
| 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 |
| 1 | Elfa | 48-396-76 | Laboratory card, 100x160mm (1/5) |
| 1 | Elfa | 75-006-22 | LED 3mm, Yellow, 2.0V, 20mA, 2.5mcd, 38° |
| 4 | Elfa | 75-006-06 | LED 3mm, Red, 2.1V, 20mA, 1.0mcd, 38° |
| 33 | LED1.de | 50747302 | LED 5mm clear, Blue, 3.4V, 20mA, 7.200mcd, 20° |
| 5 | LED1.de | 803053 | LED holder 3mm, Black plastic |
| 33 | LED1.de | 805082 | LED holder 5mm, Black plastic |
| 2 | Elfa | 55-722-35 | Control cable 4-cores, 0,25mm2, 14x0,15mm 250 V, Ø 4,6mm |
| 2 | Elfa | 48-878-24 | Metal bracket, 15x50mm |
| 3 | 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 |
| 10 | Elfa | 60-104-33 | Carbon film resistor 5% 1/4W, 330 Ohm |
| 2 | Elfa | 60-105-73 | Carbon film resistor 5% 1/4W, 4,7 K |
| 33 | Elfa | 60-104-66 | Carbon film resistor 5% 1/4W, 560 Ohm |
| 2 | Elfa | 75-355-94 | Optocoupler DIL-6, CNY17F-3 |
| 10 | Elfa | 43-708-05 | Socket connector 2,54, 1×36, female |
| 10 | Elfa | 43-702-19 | Straight pin header 2,54, 1×36, PCB |
| 1 | BilXtra | 422711 | Cigarette lighter socket, 1-pole |
| 1 | Elfa | 33-167-59 | Fuse 5x20 mm, 1.0A, quick-acting |
| 1 | Elfa | 33-150-17 | Open fuse holder, PCB, 5x20mm |
| 1 | Elfa | 33-150-25 | Open fuse holder, PCB, Protective cover |
| 1 | Elfa | 73-095-60 | Voltage regulator +5V, L78S05CV 2.0A |
| 1 | Elfa | 42-051-18 | Power Jack, panel, 2,1mm |
| 1 | Elfa | 42-048-97 | Power Jack, plug-in, 2,1mm |
| 1 | Elfa | 71-027-59 | Transistor BC547B, NPN, 45V 0.1A 0.625W |
| 1 | Elfa | 71-103-23 | Transistor BD242C, PNP, 100V 3A 40W |
| 1 | Elfa | 35-305-57 | Toggle switch, 1-pole, micro, on-off-(on) |
| 1 | Elfa | 35-305-16 | Toggle switch, 1-pole, micro, on-on |
Images
Schematic drawing
Source code
The program is written in basic, using Bascom-AVR.
'-------------------------------------------------------------- ' Thomas Jensen '-------------------------------------------------------------- ' file: AVR_DISCO v1.0 ' date: 12/08/2007 '-------------------------------------------------------------- $regfile = "attiny2313.dat" $crystal = 8000000 Config Portd = Input Config Portb = Output Config Watchdog = 1024 Dim Program As Byte , A As Byte , B As Byte , C As Byte , Ext_select As Byte , Mode_select As Byte , Random As Byte Dim Random_counter As Integer , D As Byte , Eeprom As Eram Byte Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up Ddrb.3 = 1 Pwm1a = 255 Portb.0 = 0 Portb.1 = 0 Portb.5 = 0 Portb.6 = 0 Portb.7 = 0 'get program from eeprom If Eeprom < 1 Or Eeprom > 4 Then Eeprom = 1 Program = Eeprom Start Watchdog Main: Select Case Program '1: fade quick - no pause Case 1 Portb.0 = 1 Portb.1 = 0 Portb.5 = 0 Portb.6 = 0 For A = 1 To 25 Pwm1a = Pwm1a - 10 Gosub Switches Waitms 10 Next A For C = 1 To 2 Waitms 10 Gosub Switches Next C For A = 1 To 25 Pwm1a = Pwm1a + 10 Gosub Switches Waitms 10 Next A For C = 1 To 5 Waitms 10 Gosub Switches Next C '2: pulse x 3 - pause 300ms Case 2 Portb.0 = 0 Portb.1 = 1 Portb.5 = 0 Portb.6 = 0 For A = 1 To 3 Pwm1a = 0 Waitms 10 Gosub Switches Pwm1a = 255 For C = 1 To 5 Waitms 10 Gosub Switches Next C Next A For C = 1 To 30 Waitms 10 Gosub Switches Next C '3: pulse singel - pause random ms Case 3 Portb.0 = 0 Portb.1 = 0 Portb.5 = 1 Portb.6 = 0 Pwm1a = 0 Waitms 10 Gosub Switches Pwm1a = 255 Random = Rnd(30) For C = 1 To Random Waitms 10 Gosub Switches Next C '4: strobe Case 4 Portb.0 = 0 Portb.1 = 0 Portb.5 = 0 Portb.6 = 1 Pwm1a = 0 For C = 1 To 2 Waitms 10 Gosub Switches Next C Pwm1a = 255 For C = 1 To 5 Waitms 10 Gosub Switches Next C End Select Goto Main End 'switches, mode change and random Switches: If Pind.2 = 0 Then Goto Ext_input If Pind.1 = 1 Then Mode_select = 0 If Pind.1 = 0 And Mode_select = 0 Then Mode_select = 1 Incr Program Eeprom = Program End If If Pind.0 = 0 Then Incr Random_counter If Random_counter > 500 Then Random_counter = 0 Incr Program End If End If If Pind.0 = 1 Then Random_counter = 0 If Program > 4 Then Program = 1 Reset Watchdog Return 'if external control enabled Ext_input: Portb.0 = 0 Portb.1 = 0 Portb.5 = 0 Portb.6 = 0 Portb.7 = 1 Pwm1a = 255 Do If Pind.3 = 0 And Pwm1a = 255 Then Pwm1a = 0 Ext_select = 1 End If If Pind.4 = 0 And Pwm1a = 255 Then For A = 1 To 255 Decr Pwm1a Ext_select = 2 Waitus 700 Next A End If If Ext_select = 1 And Pind.3 = 1 And Pwm1a = 0 Then Pwm1a = 255 If Ext_select = 2 And Pind.4 = 1 And Pwm1a = 0 Then For A = 1 To 255 Incr Pwm1a Waitms 1 Next A End If Reset Watchdog If Pind.2 = 0 Then Loop Else Pwm1a = 255 Portb.0 = 0 Portb.1 = 0 Portb.5 = 0 Portb.6 = 0 Portb.7 = 0 Goto Main End If End