Mood light controller v1.1

From uCtrl.net

Jump to: navigation, search
Mood light controller v1.1

Mood light controller v1.1, driven by AVR ATMega8.

Contents

Information

The mood light controller can control all kinds of RGB light, max 500mA pr. channel. The module has no voltage regulator and therefore needs 5V=. It has two color modes: one and multi color. One color means that one color is stable at the time, this gives three colors. Multi color has two stable color at the time, and this gives six colors (red, yellow, green, cyan, blue and purple). The module is powerful enough to run Prolight LEDs.

See also: Mood light v2.0

Modes

With four DIL-switches one can control how the light should behave:

  1. Pause between color change (long/short)
  2. Fade speed when changing color (long/short)
  3. Color change fade (on/off)
  4. Color mode (one color/multi color)

I/O

Inputs

  1. PC.2 DIP-Switch 1
  2. PC.3 DIP-Switch 2
  3. PC.4 DIP-Switch 3
  4. PC.5 DIP-Switch 4

Outputs

  1. PB.1 (OC1A) Red LED
  2. PB.2 (OC1B) Green LED
  3. PB.3 (OC2) Blue LED

LEDs

Kontakt-aux-mood.png

Parts list

Quantity Supplier Part number Description
1 Elfa 73-672-04 AVR-RISC, ATmega8-16PI
1 Elfa 69-687-06 Power Supply Unit, switch regulated, 5 V=, 0.8A, 2.1mm
1 Elfa 50-194-19 Plastic Enclosure (1591), 100x50x25mm
1 Elfa 48-161-87 DIL socket, 28-pin, 7,62mm
1 Elfa 70-003-91 Rectifier diode, 1A 400V, 1N4004
1 Elfa 35-400-44 DIP-switch, 4-pin
4 Elfa 48-865-60 Rubber Foot, adhesive, SJ-5012, Ø12.7x3.5
1 Elfa 48-351-79 Terminal block, pluggable, 3.5 mm, 4-pin vertical male
1 Elfa 67-008-01 Aluminium electrolytic capacitor, 10uF 25V
1 Elfa 67-008-27 Aluminium electrolytic capacitor, 22uF 25V
1 Elfa 65-851-94 Ceramic Disc Capacitor, 1 nF 100V
1 Elfa 48-396-76 Laboratory card, 100x160mm (1/5)
4 Elfa 60-106-15 Carbon film resistor 5% 1/4W, 10 K
4 Elfa 60-104-33 Carbon film resistor 5% 1/4W, 330 Ohm
4 Elfa 60-105-73 Carbon film resistor 5% 1/4W, 4,7 K
1 Elfa 33-167-42 Fuse 5x20 mm, 800 mA, 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 42-051-18 Power Jack, panel, 2,1mm
1 Elfa 55-141-12 Cable Tie Mounts, skrew, Max 5mm
3 Elfa 71-049-87 Transistor BC337-25, NPN, 45V 0.5A 0.8W

Images

Schematic drawing

Mood-light-11 circuit.png

Files

Source code

The program is written in basic, using Bascom-AVR.

'--------------------------------------------------------------
'                         Thomas Jensen
'--------------------------------------------------------------
'  file: AVR_MOOD_LAMP_v1.1
'  date: 14/03/2007
'--------------------------------------------------------------
$regfile = "m8def.dat"
$crystal = 1000000
Config Watchdog = 1024
Config Portb = Output
Config Portc = Input
Dim A As Byte , R As Integer , Speed As Integer , Fade As Integer , Random As Integer
 
Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Timer2 = Pwm , Prescale = 1 , Compare Pwm = Clear Down
 
'input
'2. Stable time
'3. Fade speed
'4. Direct crossover
'5. Mode one/two color
 
Ddrb.1 = 1
Ddrb.2 = 1
Ddrb.3 = 1
 
Pwm1a = 255
Pwm1b = 255
Ocr2 = 255
 
 
For A = 1 To 255                                            'boot start blue LED
Decr Ocr2
If Pinc.3 = 0 Then Waitms 5 Else Waitms 15
Next A
 
Gosub Switches
 
Main:
Do
 
If Pinc.5 = 0 Then Goto Flerfarget
 
For A = 1 To 255                                            'increase red, decrease blue
Decr Pwm1a
Incr Ocr2
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'decrease red, increase green
Decr Pwm1b
Incr Pwm1a
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'decrease green, increase blue
Decr Ocr2
Incr Pwm1b
Waitms Fade
Next A
 
Gosub Switches
 
If Pinc.5 = 1 Then Loop
If Pinc.5 = 0 Then Goto Flerfarget
 
Switches:
If Pinc.2 = 0 Then Speed = 500 Else Speed = 200
If Pinc.3 = 0 Then Fade = 5 Else Fade = 15
If Pinc.4 = 0 Then Fade = 0
 
Random = Rnd(speed)
 
For R = 1 To Random
Waitms 10
Next R
 
Return
 
Flerfarget:
Pwm1a = 255
Pwm1b = 255
 
Ocr2 = 0                                                    'start blue
Do
If Pinc.5 = 1 Then
     Pwm1a = 255
     Pwm1b = 255
     Ocr2 = 0
     Goto Main
   End If
 
For A = 1 To 255                                            'increase red
Decr Pwm1a
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'decrease blue
Incr Ocr2
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'increase green
Decr Pwm1b
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'decreate red
Incr Pwm1a
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'increase blue
Decr Ocr2
Waitms Fade
Next A
 
Gosub Switches
 
For A = 1 To 255                                            'decrease green
Incr Pwm1b
Waitms Fade
Next A
 
Gosub Switches
Loop
End
Personal tools
Namespaces
Variants
Actions
Navigation
Categories
projects
Toolbox