Mood light v1.0
From uCtrl.net
Mood light v1.0, driven by AVR ATMega8.
Contents |
Information
YouTube Video: Mood-lamp using ATmega8
Nine LEDs, three of each color (red, green and blue) is mounted in the bottom of a ice glass. The LEDs are soldered onto a PCB that lies at the bottom and point upwards, illuminating the entire glass. A AVR device controls the LEDs using PWM, this gives the option of regulating the intensity of the LEDs and fade between colors.
Modes
With four DIL-switches one can control how the light should behave:
- Pause between color change (long/short)
- Fade speed when changing color (long/short)
- Color change fade (on/off)
- Color mode (one color/multi color)
I/O
Inputs
- PD.0 DIP-Switch 1
- PD.1 DIP-Switch 2
- PD.2 DIP-Switch 3
- PD.3 DIP-Switch 4
Outputs
LEDs
Parts list
| Quantity | Supplier | Part number | Description |
| 1 | Elfa | 73-672-04 | AVR-RISC, ATmega8-16PI |
| 1 | Elfa | 69-808-66 | Power Supply Unit, regulated, 9 V=, 300 mA, 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-20 | Terminal block, pluggable, 3.5 mm, 4-pin skrew female |
| 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 |
| 2 | Elfa | 67-008-68 | Aluminium electrolytic capacitor, 47uF 25V |
| 1 | Elfa | 65-851-94 | Ceramic Disc Capacitor, 1 nF 100V |
| 3 | Elfa | 75-005-80 | LED 5mm clear, Blue, 4.9V, 20mA, 350mcd, 12° |
| 3 | Elfa | 75-016-79 | LED 5mm clear, Green, 2.1V, 20mA, 385mcd, 6° |
| 3 | Elfa | 75-016-04 | LED 5mm clear, Red, 2.0V, 20mA, 140mcd, 6° |
| 3 | Elfa | 60-722-84 | Metal film resistor 1% 0,6W, 1 K |
| 4 | 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 |
| 4 | Elfa | 60-105-73 | Carbon film resistor 5% 1/4W, 4,7 K |
| 1 | Elfa | 33-167-18 | Fuse 5x20 mm, 400 mA, quick-acting |
| 1 | Elfa | 33-150-17 | Open fuse holder, PCB, 5x20mm |
| 1 | AUX-01 | Voltage regulator +5V, 1.0A | |
| 1 | Elfa | 42-051-18 | Power Jack, panel, 2,1mm |
| 3 | Elfa | 71-027-59 | Transistor BC547B, NPN, 45V 0.1A 0.625W |
Images
Schematic drawing
Resources
Source code
The program is written in basic, using Bascom-AVR.
'-------------------------------------------------------------- ' Thomas Jensen '-------------------------------------------------------------- ' file: AVR_MOOD_LAMP ' date: 13/01/2007 '-------------------------------------------------------------- $regfile = "m8def.dat" $crystal = 1000000 Config Watchdog = 1024 Config Portb = Output Config Portd = Input Dim A As Byte , R As Integer , Speed As Integer , Fade As Integer , Random As Integer Dim Hyst1 As Byte , Hyst2 As Byte , Hyst3 As Byte 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 '0. Speed 1 '1. Fade '2. Crossover '3. Mode Ddrb.1 = 1 Ddrb.2 = 1 Ddrb.3 = 1 Ocr2 = 0 Pwm1a = 255 Pwm1b = 255 Main: Do For A = 1 To 255 Decr Pwm1a Incr Ocr2 Waitms Fade Next A Gosub Switches For A = 1 To 255 Decr Pwm1b Incr Pwm1a Waitms Fade Next A Gosub Switches For A = 1 To 255 Decr Ocr2 Incr Pwm1b Waitms Fade Next A Gosub Switches Loop Switches: If Pind.0 = 0 Then Speed = 500 Else Speed = 200 If Pind.1 = 0 Then Fade = 5 Else Fade = 15 If Pind.2 = 0 Then Fade = 0 If Pind.3 = 0 Then Goto Hysterisk Random = Rnd(speed) For R = 1 To Random Waitms 10 Next R Return Hysterisk: Pwm1a = 255 Pwm1b = 255 Ocr2 = 255 Do If Pind.3 = 1 Then Pwm1a = 255 Pwm1b = 255 Ocr2 = 0 Goto Main End If Hyst1 = Rnd(255) For A = 1 To Hyst1 Decr Pwm1a Waitms Fade Next A Hyst2 = Rnd(255) For A = 1 To Hyst2 Decr Pwm1b Waitms Fade Next A Hyst3 = Rnd(255) For A = 1 To Hyst3 Decr Ocr2 Waitms Fade Next A 'senk For A = 1 To Hyst1 Incr Pwm1a Waitms Fade Next A For A = 1 To Hyst2 Incr Pwm1b Waitms Fade Next A For A = 1 To Hyst3 Incr Ocr2 Waitms Fade Next A Gosub Switches Loop End
