Dimmable LED Christmas Star

by RobBest in Circuits > Microcontrollers

305 Views, 1 Favorites, 0 Comments

Dimmable LED Christmas Star

Old_vs_New.JPG

Many years ago my Daughter made Christmas Stars using conventional Christmas lights. Since one of the lights was broken and to save electricity I replaced these lights by warm white 10 mm LEDs. In order to set the brightness of the LEDs to the correct level, I added a dim feature to it.

In the picture you see the current version with the conventional lights on the left and the new version with the LEDs on the right.

As always I built this project around my favorite micro controller the PIC, using the JAL programming language.

Required Components and Schematic Diagram

Schematic_Diagram.png

You need to have the following components for this project:

  • A piece of breadboard
  • PIC microcontroller 12F675
  • An 8-pin IC socket
  • A transistor BC639 or compatible
  • Ceramic capacitor 100nF
  • Electrolytic capacitor 220uF/16V
  • Resistors: 2 * 10k, 1 * 470 Ohm, 10 * 100 Ohm
  • 10 * warm white LEDs of 10 mm
  • A push button
  • A 5 Volt / 300 mA power supply, e.g. a USB charger

See the schematic diagram on how to connect the components.

Designing and Building the Electronics

P1050198.JPG
P1050197.JPG
P1050206.JPG

The device operates at 5 Volt and draws around 160 mA when the LEDs are at maximum brightness and about 25 mA when at minimum brightness. The LEDs stay on at a minimum brightness so that you know Christmas star is switched on..

Control of the LEDs is done by a PIC12F675 microcontroller running at an internal clock of 4 MHz. A push button is used to turn the LEDs on or off and to control the brightness of the LEDs. The total current used by all LEDs is more than a PIC can drive from its output so a transistor is used that is capable of switching more than 200 mA. The BC639 can switch a current up to 1 Ampere.

In the pictures you can see how the circuit was built.

The Software

As already mentioned, the software is written for a PIC12F675 using the JAL programming language. Any other small or larger PIC can be used for this purpose as long as the PIC has non-volatile memory on board (EEPROM). The program uses only 321 bytes of ROM and 16 bytes of RAM.

Brightness control is done by using Pulse Width Modulation (PWM). Since the used PIC does not have on-board hardware for making the PWM signal, this signal is created in software using a timer.

When the device is powered up, it reads the last brightness setting from the EEPROM and uses that the set the duty cycle of the PWM signal. The push button provides the following functionality:

  • When pressing it for a short time, the PIC switches the LEDs on or off (toggle)
  • When pressing it for a long time, the PIC increases or decreases the brightness of the LEDs. Each time the push button is released it switches from increasing the brightness to decreasing the brightness or the other way around
  • After changing the brightness, the new brightness value is stored in the EEPROM

Since the PIC has some floating input pins, the weak pull-up resistors in the PIC are activated for all unused pins.

The JAL source file and the Intel Hex file for programming the PIC are attached. If you are interested in using the PIC microcontroller with JAL – a Pascal like programming language – visit the JAL website.

The Final Result

Dimmable LED Christmas Star

In the video the following items are demonstrated:

  • Power on and set the LED brightness to the last selected brightness using a soft start
  • Increase the brightness of the LEDs by pressing the push button for a long time
  • Switch the LEDs off and on by pressing the push button twice for a short time
  • Decrease the brightness of the LEDs by pressing the push button for a long time
  • Note that when the dim functionality is used, the program switches between increasing or decreasing the brightness each time the push button is released

The blinking of the LEDs seen in the video is caused by the camera and is not visible for the human eye. The LEDs operate at a frequency of about 80 Hz.

Have fun building your own project and looking forward to your reactions and applications.