19 led animated christmas star

38
1) 19 LED Animated Christmas Star As promised, now that I have largely finished the Christmas Star I am documenting it for those that have emailed me for the details. Hardware The hardware is quite similar to the Christmas Tree except 19 of the possible 20 drive vectors of the K5 charliplexing topology are used. The drive board is identical, except I am using the pin-compatible but more resourced Atmel ATtiny45 to fit the more sophisticated software. Construction began with designing the star and LED layout. While a fairly simple geometrical problem to construct with compass and straight-edge I decided to use software to render a cutting template for accuracy and repeatability. Some postscript was written to render both the star outline and place the 19 holes for the LEDs. Using postscript allowed many variations to be assessed before the final 6- pointed star was settled upon. The resulting full-size template image was printed out and tacked (in waste places) with some paper adhesive to the dense "art board" cardstock used selected as the basic substrate of construction.

Upload: jane-josanin-s-elizan

Post on 30-Oct-2014

134 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 19 LED Animated Christmas Star

1) 19 LED Animated Christmas Star As promised, now that I have largely finished the Christmas Star I am documenting it for those that have emailed me for the details.

Hardware The hardware is quite similar to the Christmas Tree except 19 of the possible 20 drive vectors of the K5 charliplexing topology are used. The drive board is identical, except I am using the pin-compatible but more resourced Atmel ATtiny45 to fit the more sophisticated software.

Construction began with designing the star and LED layout. While a fairly simple geometrical problem to construct with compass and straight-edge I decided to use software to render a cutting template for accuracy and repeatability. Some postscript was written to render both the star outline and place the 19 holes for the LEDs. Using postscript allowed many variations to be assessed before the final 6-pointed star was settled upon. The resulting full-size template image was printed out and tacked (in waste places) with some paper adhesive to the dense "art board" cardstock used selected as the basic substrate of construction.

Page 2: 19 LED Animated Christmas Star

The 5 mm LED holes were then punched out using the partner's eyelet punch and the outline cut carefully with a craft knife and steel rule. The punching was easy and very clean compared to drilling, like the Dekatron emulator I was very pleased with the result. The border cutting was a bit more difficult as significant care and a large amount of cutting pressure (in several passes) was required because of the thickness and density of the cardboard.

Page 3: 19 LED Animated Christmas Star

Next the 19 bright white defused LEDs were inserted, paired up and soldered together in reverse-parallel pairs.

Page 4: 19 LED Animated Christmas Star

Each was numbered and the charlieplexing scheme topology translated into a corresponding wiring list that was all soldered up using 200 um copper wire with the wiring pencil.

Page 5: 19 LED Animated Christmas Star

The five trailing wires were twisted into a bundle and terminated (arbitrarily) in a 5 pin fragment of IC socket as a plug.

Page 6: 19 LED Animated Christmas Star

Similarly to the Tree project, the drive-line to LED mappings were recovered by injecting a current-limited signal into each of the 20 possible pin pairings and polarities. A table was constructed and put into the firmware indexed by LED identifier. The 0 is the centre LED, they then number spiralling out anti-clockwise starting from the top inner most LED. The 20th drive vector is unused, but I did toy with the idea of making the centre LED a reverse-parallel bi-colour device - I decided against it as the brightness of the available devices was significantly poorer and the pure white star is more aesthetically pleasing.

Page 7: 19 LED Animated Christmas Star

Finishing touches to the hardware were added later, including attaching a 4xAAA cell holder and the MCU board to the back of the star using double-sided foam tape "dots" (from the partner's craft supplies), and placing a slide-action power switch with some hot-melt glue. Finally a cone was rolled from overhead transparency (to mate with my fibre-optic Christmas tree) and socketed onto the star back using a small piece of plastic tube and a ring of hookup wire held in place with hot-melt glue. This socket system enables the cone and star to be easily separated.

Software The software builds upon the Christmas Tree prototype, but controls more LEDs and adds the ability to execute byte-coded animation logic at a variable rate rather than just cycling through a simple list of states. The charlieplexing routine and control vector encoding is identical to the tree (but uses a 32 bit state vector instead of a 16 bit one because of the larger number of LEDs) and simply runs as fast as possible. The display state transitions are handled by a ~30.5 Hz timer interrupt that sets a global flag (after an adjustable number of interrupts). When the global flag is set the byte-code interpreter is called from the charlieplexing loop. The interpreter can change the display state or perform other tasks before surrendering the CPU back to the charlieplexing (until the next timer interrupt) - it can however reset the global flag and cause itself to be recalled immediately to execute multiple instructions before allowing the display multiplexing to continue. In addition to "immediate" style display vector assignment and individual LED set/unsets, the instruction set includes operations to change the display rate, set state from a pseudo-random source, perform display geometry specific rotations, or execute loops.

Page 8: 19 LED Animated Christmas Star

Originally the program just fit in the Atmel ATtiny13's 1k of FLASH and 64 byte RAM, but when the rotate operations were added and additional state needed for the looping constructs there was insufficient room available so I was forced to upgrade to the ATtiny45. The increase in resources allowed the addition of the random number generation routines, which vastly improves the display options available. It is likely possible to squeeze the bytecode interpreter into the tiny13 by using ASM exclusively, but the C-level programming is much more expedient. As usual the software is taking much longer to perfect than the hardware. The Star is in place on the Christmas tree, but improvement ideas continue. Effort is under way to back-port the new byte-code interpreter features to the Tree code. The Tree with its 16 bit display state may permit an abridged version of code to fit in a tiny13. Alternatively a PC hosted interpreter could generate the state list for the original firmware from the more compact and easily used format. The rotate operations specific to the display geometry are much easier to work with than hand-computing the next state. I have already sketched an improved byte-code instruction set for devices like the tree that have just 16 bit display vectors - which allows compression of many immediate values into a nibble of the byte-code itself. Generic mask-and-rotate maps could be used in other geometries, leading into my other desire to make a PC-hosted tool for program design assistance. Pushing the 8-pin devices to their 6-line, 30-LED limit is also a natural progression, but before I do that I need to make my HV-programmer a more permanent circuit (it still sits on a breadboard).

Page 9: 19 LED Animated Christmas Star

2) Grantronics Projects

Christmas Star

Christmas Star

Here is a fun project that can add that

"something different" to your Christmas tree. Or put it in the front

window to impress the neighbours!

History

This project started just before last Christmas when my daughters asked "why don’t we have any flashing Christmas tree lights?" So, while they were out shopping, my son and I grabbed a dozen LEDs, some ribbon cable and a microcontroller. While my son wired up the LEDs, I wrote some simple software. It was all installed and running when they came home after spending all my money (that’s why we didn’t have lights before…)! The smiles on their faces made it all worth while! I then resolved to do something better for next Christmas... Why use a Microcontroller?

Using a PC parallel port to control external devices is a popular approach these days but I certainly couldn’t afford to tie up a PC for the few weeks leading up to Christmas just to flash a few LEDs! Not to mention the power bill! So, why not use a small microcontroller? They are cheap and easy to use and if the design doesn’t work first time (when does it?), you simple re-program it. Also, you can easily create something using a micro that is the equivalent of many discrete logic chips. In this case, the circuit is simple enough to lash up on VeroBoard™ though it is much easier to use a printed circuit board. To do the star in discrete logic would be a nightmare! Given a few inexpensive software tools, a microcontroller such as the Atmel AT89C2051 should be just as easy to use as a handful of 4000-series CMOS chips. In my experience, the micro is usually easier! Another reason for using a micro is that micros are the future of electronics. While it is useful to know how to design with 4000-series logic, most new products require more than can be easily done in discrete logic. I believe there is actually a commercially available toaster that uses a micro! While some would say that this is an extreme example, it does indicate how far micros have entered our lives.

Page 10: 19 LED Animated Christmas Star

So what’s in a ‘2051?

The Atmel AT89C2051 is a relatively recent derivative of the venerable 8051. It comes in a diminutive 20 pin skinny-DIP plastic package and contains 2k bytes of program memory, 128 bytes of RAM, 15 programmable I/O lines, on-chip oscillator, two 16 bit counter/timers, six interrupt sources and a full duplex serial port (UART). This all sounds very much like a small 8051 until we add that the program memory is re-programmable Flash with 1000 erase/write cycles, the oscillator runs to 24MHz (double that of the original 8051), the I/O pins can sink 20mA for directly driving LEDs and two I/O pins are connected to an on-chip analogue comparator! The Hardware

The heart of the hardware is, of course, the Atmel ‘2051 micro. To make it start thinking, we need a reset circuit consisting of C7. D2 forces C7 to discharge quickly when power is removed. To set how fast it thinks, we need an external crystal X1 and associated capacitors C1 and C2. Note that the crystal could be replaced by a 12MHz ceramic resonator. This allows the ‘2051 to execute an instruction every 1 or 2us. As you can see from the schematic, the 30 LEDs are connected in an X-Y matrix. Why 30 LEDs? Engineering is full of trade-offs or compromises. I wanted a 5 pointed star so the number had to be divisible by 5. For aesthetic reasons, we need an even number of LEDs per point. Six LEDs per point looked "about right". The next step up would have been 40 LEDs which would have required 13 I/O pins to drive them and a more complicated PCB. We can drive 30 LEDs from only 11 I/O pins using a process called multiplexing. The appropriate combination of LEDs in a column is switched on for a short time (about 2ms in this case). This process is repeated for each column in turn taking 10ms for a full cycle. Provided the multiplexing is done quickly enough, the persistence of the human eye "fills in the gaps" and we see any combination of LEDs on without any flicker. The minimum practical multiplexing frequency is about 100Hz which is the frequency used by the star. The power supply uses the ubiquitous 7805 three terminal regulator with bypass capacitors C4 and C5. Diode D1 provides reverse polarity protection. The maximum current drawn by the star is about 150mA with all LEDs on but less than about 50mA for most patterns. The maximum temperature rise of the 7805 when the star is run from a typical 9Vdc unregulated plug-pack is about 30 degrees which is quite acceptable. It gets warmer when run from a 12Vdc unregulated plug-pack and should be provided with a small heatsink. The Software

In the spirit of Christmas, we are making the basic source code available for free! An extended version that uses the EEPROM for storage is available at minimal cost. The software was written in the C language using the low cost Dunfield Development Systems Micro/C compiler. There is nothing particularly "smart" or "tricky" about the software – it was written to be easy to understand and to encourage use of small micros. Consequently, there are no interrupt routines and no use of the counter/timers, the UART or the comparator though Micro/C can make use of these resources. The software is table driven. This means that the display patterns and sequences are determined by data stored in a table (an array of bytes). There is a simple interpreter that scans through the table to perform the specified operations. The defined byte values are listed in the following table.

Page 11: 19 LED Animated Christmas Star

Byte value or range Operation

01 to 30 (0x01 to 0x1e) Turn on LED 1 to 30

33 to 62 (0x21 to 0x3e) Turn off LED 1 to 30 (LED number = byte – 32)

64 (0x40) Go back to byte after loop start

65 to 79 (0x41 to 0x4f) Loop start, count = byte – 64

128 (0x80) Delay (use last delay count), each count = 10ms

129 to 191 (0x81 to 0xbf) Delay, count = byte – 128, each count = 10ms

253 (0xfd) All LEDs on

254 (0xfe) All LEDs off

255 (0xff) End of table

Note that there are quite a few undefined values so future expansion is possible. Putting it all together

Assembly is quite straight forward. You will need a soldering iron with a fine tip, preferable temperature controlled to about 600

oF or 320

oC. Carefully check for shorts between tracks

and broken tracks. Fit the lowest parts first – the wire links and resistors and diodes. Next, fit the crystal (or resonator) and the IC sockets for the micro and EEPROM. Fit the transistors, capacitors and LEDs. Pay particular attention to the orientation of the LEDs – they don’t work when installed backwards! Finally, install the regulator and power socket. Do another close visual inspection looking for solder bridges especially on the transistor pads. Connect power and check for 5Vdc (4.8V to 5.2V) from U1 pin 20 (+) to U1 pin 10 (-). If all is OK, remove power, plug in the micro and turn it on. The two holes near LED1 may be used to hang the star and the holes near SK1 may be used to secure the plug pack cable. Finally, the appearance of the star may be enhanced by placing a piece of red cellophane over the front. Fault finding

5Vdc not present: Check the applied power polarity – the centre pin of SK1 must be positive. Check that D1 is correctly fitted. Check tracks from SK1 via D1, the 7805 to U1 for breaks or shorts. One LED does not work: It may be inserted backwards or it may be shorted. One group of adjacent LEDs does not work: Check circuitry and soldering around the appropriate column drive transistor. Several individual LEDs do not work: Check the corresponding row drive circuitry. Remember, faulty components are rare, soldering problems are more common! The future

The star is still evolving. That is part of the attraction of using a micro – it is so easy to change the behaviour by changing the software. And what about that EEPROM? Well, an enhanced version of the star will read its data from the EEPROM for much longer sequences. You can download the current software source. If you don’t have Internet access, send us a stamped ($1) self addressed envelope with an IBM format 3.5" disk and we will send you the current software files.

Page 12: 19 LED Animated Christmas Star

We hope you have as much fun building the star and playing with the software as we did creating it. Enjoy!

Parts List

Quantity Description

Hardware

1 PC board type STAR1SS

1 "DC" connector, 2.1mm (SK1)

1 12MHz crystal or ceramic resonator (X1)

1 8 pin IC socket (optional)

1 20 pin IC socket

1 9Vdc 150mA plug pack power supply (eg, Jaycar MP-3003)

Semiconductors

1 AT89C2051 (programmed) (U1)

1 7805 (or LM340T-5) regulator (U2)

1 24C16 EEPROM (U12) (optional, enhanced version only)

30 Red LEDs (LED1-LED30)

5 BC557 or similar PNP transistor (Q1-Q5)

1 1N4002 power diode (D1)

1 1N4148 or 1N914 diode (D2)

Resistors (0.25W, 5% tolerance)

5 470R (R1-R5)

6 120R (R6-R11)

Capacitors

2 27p ceramic (C1-C2)

3 100n monolithic (C3-C5)

1 4.7uF 16VW+ RB electrolytic (C7)

Note: The LEDs should be relatively bright diffused types (about 50mcd).

Page 13: 19 LED Animated Christmas Star
Page 14: 19 LED Animated Christmas Star

3) Christmas Tree

Christmas Tree

Here is a fun project to put on your Christmas Tree or in your front

window to impress the neighbours.

Multi-Coloured Christmas Tree Looking for something different to build this Christmas? Try our Multi-Coloured Christmas Tree. It will look great at the top of your Christmas tree or in the front window. Last November, we published the very popular Christmas Star. This year, our "just for fun" project is in the shape of a tree but we have gone one step further by using bi-coloured LEDs. There are many different light patterns and each LED can produce 16 different colours. Yes, you guessed it. The Tree is controlled by a microcontroller but this one is different. While it can be programmed by most "high-end" (expensive) chip programmers, it can also be programmed (and re-programmed) by a PC parallel port with minimal hardware. This makes it ideal for hobbyists. If you have been avoiding microcontrollers because of the cost of the programming hardware, now there is no excuse! And most of the development software can be downloaded free from the Internet – there goes another excuse! Circuit description The key to understanding any circuit is "divide and conquer" - break it down into functional blocks. There are 3 main blocks in the Tree. The first, the power supply, is very straight forward. 9Vdc should be applied to SK1. Reverse polarity protection is provided by D1. U2 then regulates down to 5V for the LEDs and the logic. Bypass capacitors C4 and C5 ensure the 7805 remains stable. Next is the microcontroller or MCU. In previous projects, we used the Atmel AT89C2051. However, the I/O port structure is not quite suitable for this application so we have used the similar Atmel AT90S2313. The main feature influencing this decision is that the ‘2313 outputs can be "turned off" while the ‘2051 outputs always have pullups enabled. When I said the ‘2313 is similar to the ‘2051, I was referring to the arrangement of I/O pins and their functions. Inside, the two chips are quite different. See the sidebar "What’s in the AT90S2313" for a description of the microcontroller. U3 (24C16) is a serial EEPROM where the pattern data is stored. While the ‘2313 has some EEPROM on chip (128 bytes), this was not enough for the number of patterns we wanted to provide. The final block is, of course, the LEDs. At first glance, the PCB looks like it contains 32 LEDs. In reality, there are 64 LEDs as each is a bi-colour LED capable of glowing red or green. Two pin bi-colour LEDs were chosen to reduce the number of PCB tracks and MCU pins required – the three pin LEDs would have been easier to drive and would have required more MCU pins.

Page 15: 19 LED Animated Christmas Star

As expected, the LEDs are multiplexed. To control so many LEDs with so few MCU pins, we connect the LEDs in a matrix of 4 columns with 8 LEDs in each and use 12 pins. Multiplexing is where each column of LEDs is activated for a short time followed by the next column. If each time slot is short enough, our eyes don’t see any flicker. While there are only 4 columns on the schematic, we have to drive each column twice in each multiplex cycle (once in each polarity) so we can activate the red and green LEDs. Consequently, each LED’s timeslot is 1/8 of the total. This is a practical minimum duty-cycle as the brightness reduces. Resistors R6 to R13 set the peak LED current to about 25mA. Because there can only be 8 LEDs on at any time, the total maximum current drawn by the Tree is about 200mA. You can make the display slightly brighter by substituting 39 Ohm resistors (about 30mA per LED) but a small heatsink will be required on the regulator. Total current will then be about 250mA. Any 9Vdc plug pack rated at 250mA or more should be suitable. In practice, a 150mA 9V unregulated plug pack supply works with the 47R resistors as maximum current draw only occurs for "full brightness yellow" which does not occur very often. Note that the original Silicon Chip article had R6 to R13 as 100R. This value will work with a 12V supply but at reduced brightness. Unfortunately, the microcontroller can’t drive the LEDs directly because maximum current ratings would be exceeded (risking loss of magic smoke!). So each pin is buffered by an emitter follower. Because each LED package has two LEDs connected in inverse parallel, the emitter followers have to be "bi-polar" so they can both source and sink current. So, where a more conventional LED matrix would have 4 high current source drivers and 8 lower current sink drivers, this design has drivers that can source and sink. Software The software source code for the Tree is available for download from our web site at www.grantronics.com.au. The software was written in C and compiled by the Dunfield Micro/C compiler which, coincidentally(!), is available from Grantronics. As each byte of pattern data is read in, it is processed by a simple interpreter. So each byte is an instruction such as "set colour to red" or "set Led 22 to the current colour" or "pause for 500ms". All the complex light patterns are built from these and similar simple instructions. If you want to know more about the instruction codes, download the software. Assembly Whew! With all the technical stuff out of the way, lets get the soldering iron going and start building. Your soldering iron should be temperature controlled (about 600F, 320C) with a fine tip. Visually check the PCB for shorts between tracks and broken tracks. As usual, start with the lowest items such as wire links and resistors. Next, fit the IC sockets, crystal, small capacitors, regulator and input diode. The regulator should be bolted to the PCB to provide some heatsinking. The transistors should be fitted next. All the BC547’s face one way and all the BC557’s face the other way. Now you can fit the LEDs. Be careful to insert them the right way and don’t apply too much heat as the leads are very short when the LED is pushed down against the board. Finally, C3 and the DC power connector should be fitted. Testing Carefully check your soldering – use a magnifying glass and a good light. Mistakes found now are less embarrassing than damaged components later! Don’t plug in the two DIL ICs yet. Do a quick continuity check using your multimeter’s diode check range between U1 pin 10 (-) and every other pin of U1. There should be no shorts or diode junctions. Reverse the probes and you should see diodes (base-collector junctions) on the 12 pins that connect to the LED matrix. A similar test should be performed with U1 pin 20 (+) as the common pin. This may seem like a lot of work but a solder blob shorting a U1 I/O pin to 0V or +5 may damage U1 and spoil your Christmas! When you are satisfied with your workmanship, connect 9Vdc. No LEDs should light. Measure U1 pin 10 (-) to pin 20 (+). You should have 4.8V to 5.2V. If all is well, remove power and plug in U1 and U3. Make sure they are correctly oriented and be careful not to bend any pins as you plug them into the sockets.

Page 16: 19 LED Animated Christmas Star

Turn your Tree on and the display sequence should start within a few seconds. If it doesn’t work… Modern electronic components are very reliable and faulty new components are very rare. All microcontrollers and EEPROMs programmed by Grantronics are individually tested so problems with these parts are unlikely. The reality is that the most common causes of problems are soldering, wrong component or wrong component orientation. So the first step in sorting out problems is to thoroughly check your workmanship (or should that be workpersonship…?). After that, we need to get more logical. If a few LEDs don’t work, are they all in a single column or row? Maybe they only glow red and not green? The column drivers go high and the rows go low for red and vice versa for green. To help with fault finding, the first few patterns are simple "all one colour" displays. The patterns get more interesting after that… I hope you have as much fun building and watching the Christmas Tree as we did designing it. Finally, thankyou to the people at BEC Manufacturing (Brisbane) for making the PCBs in time for this issue. We hope you have as much fun building the Tree and playing with the software as we did creating it. Enjoy! Modifications

If you must run the Tree from a 12V supply, mount the regulator on the back of the PCB (plastic body to PCB, bend the legs up instead of down) with a small heatsink. You will need a longer screw with a couple of nuts as a spacer.

Parts List

Quantity Description

Hardware

1 PC board type TREE

1 "DC" connector, 2.1mm (SK1)

1 4MHz crystal or ceramic resonator (X1)

1 8 pin IC socket

1 20 pin IC socket

1 9Vdc 150mA plug pack power supply (eg, Jaycar MP-3003)

1 M3 x 6mm screw and nut

Semiconductors

1 AT90S2313 (programmed) (U1)

1 7805 (or LM340T-5) regulator (U2)

1 24C16 EEPROM (programmed) (U3)

32 Bi-Colour LEDs (LD1-LD32)

12 BC547 or similar NPN transistor (Q1-Q23, odd numbers)

12 BC557 or similar PNP transistor (Q2-Q24, even numbers)

1 1N4002 power diode (D1)

Page 17: 19 LED Animated Christmas Star

1 1N4148 or 1N914 diode (D2)

Resistors (0.25W, 5% tolerance)

8 47R (R6-R13)

Capacitors

2 27p ceramic (C1-C2)

3 100n monolithic (C4-C6)

1 1uF 16VW+ RB electrolytic (C3)

Note: The LEDs used in the prototype were Jaycar ZD-1734 rated at 30mA.

What’s in the AT90S2313? The AT90S2313 is a member of the Atmel AVR family of microcontrollers that range from tiny 8 pin packages to a 64 pin feature-packed "monster". Here is a short summary of the features of the ‘2313:

118 instructions, most single clock cycle execution 32 x 8 bit general purpose working registers Up to 10 MIPS throughput at 10MHz 2k bytes (1k words) of In-System-Programmable Flash for program storage (endurance 1,000

erase/write cycles) 128 bytes of SRAM 128 bytes EEPROM (endurance 100,000 erase/write cycles) May be locked for program and EEPROM data security One 8-bit timer/counter with separate prescaler One 16-bit timer/counter with separate prescaler, compare and capture modes and 8, 9 or 10-

bit PWM On-chip analogue comparator (rail to rail inputs) Programmable watchdog timer with separate on-chip oscillator SPI serial interface (for In-System programming only) Full duplex UART Low power idle and power down modes External and internal interrupt sources 15 programmable I/O lines in a 20 pin package I/O pins can sink up to 20mA for direct driving LEDs 2.7 – 6.0V (4MHz parts) or 4.0 – 6.0V (10MHz parts)

Page 18: 19 LED Animated Christmas Star
Page 19: 19 LED Animated Christmas Star

4) LED flasher

I made LED flash circuit which is often used as the PIC software making practice.

This circuit controls the blink of eight LEDs with the software of PIC. The blinking pattern can be changed with five switches.

Pattern 1

Pattern 2

Pattern 3

Pattern 4

Pattern 5

Link for the patterns: http://www.piclist.com/images/www/hobby_elec/e_pic6_1.htm

Specification

PIC PIC16F84A

Processor Frequency 10MHz

LED High brightness LED x 8

Blink pattern Five kinds

Circuit drawing of LED flasher

Page 20: 19 LED Animated Christmas Star

Pattern drawing of LED flasher

(Wiring side)

Key-in circuit

Five pins from RA0 to RA4 are used as the input pin. These pins are pull-uped with 10K ohm resisters. So, when a switch isn't pushed, the input

becomes H level ( +5V ). and when a switch is pushed, it will become L level ( 0V ). When

the switch closes, the chattering occurs. The chattering is the phenomenon which occurs with

the bound of the point of contact. The opening and shutting of a point of contact is repeated in

short time.. I don't put the prevention circuit of the chattering at the circuit this time. When the software

detects that the switch is closed once, the blink processing of LEDs are executed in the time

which is longer than the chattering.

LED control circuit

Eight pins from RB0 to RB7 are used for the output pin. The anode side of the LED is connected with +5 V and the cathode side is controlled by PIC

via the resistor. So, when the output of PIC is H level (+5V), the LED goes out and when the

output of PIC is L level (0V), the LED lights up. I am using high brightness type LED to

Page 21: 19 LED Animated Christmas Star

make an current flow little.

Clock generator circuit

This is the circuit which used 10-MHz resonator. It is very simple.

Power supply circuit

3 terminal regulator is used to get +5V output from +12V power in. Because it is suppressing the current of the LED, a 100 mA-type regulator is

enough.

Page 22: 19 LED Animated Christmas Star

5) Wave JT - LED Chaser with Joule Thief

Step 1 — Features

Wave JT is not only powered by a single AA battery, but it's feature rich. Compact & streamlined design. Uses only one AA battery (or any 1.5V battery you can hook up to). Works well with rechargeables (NiMH or NiCd) too. Eight LEDs, each with its own 256 level brightness control. Energy efficient - works even with a run-down battery, down to 0.6V (0.8V to startup).

Page 23: 19 LED Animated Christmas Star

Step 2 — Circuit Schematics The power supply (voltage booster) part of schematic shows somewhat typical Joule Thief circuit, plus a

few extra parts. D1 (Schottky diode) and C2 form a rectifier to create DC voltage out of the Joule Thief. Zener diode D2 is

added to "clamp" or limit the voltage at 5.1V to prevent damaging the microcontroller (maximum voltage this chip can withstand is 6V).

Without the Zener diode there, the output voltage from the boost circuit can go over 6V when no LEDs are lit.

Page 24: 19 LED Animated Christmas Star

Step 3 — Parts Here are the parts. LEDs should be of "super bright" variety. Standard LEDs are not bright enough for this circuit. Either 3mm

or 5mm sizes can be used, however the PCB is somewhat optimized with 3mm LEDs. 5mm LEDs hang off the edge of the PCB a slight bit. Make sure to use the same LEDs for all eight of them. (Of course you can experiment mix & matching if you like..

Parts list is included in the schematic PDF.

Page 25: 19 LED Animated Christmas Star

Step 4 — Assembly The assembly is very straightforward. Insert the parts into the PCB, and solder them. Start with lower

profile components and move on to larger, taller ones. Transistors, diodes, electrolytic capacitor and LEDs have polarities, so make sure to insert them in the

correct orientation. Battery holders need a bit of force to snap into the holes. They attach from the back side of PCB as you can see in the picture.

Once everything is soldered in place, double check the part placement, orientation and solder joints for shorts and bad (cold) connections.

Page 26: 19 LED Animated Christmas Star

Step 5 — Programming the Microcontroller (PIC) Download the firmware HEX file here. Insert 5-pin header to PICKit 2/3 or other PIC programmer, and stick the other end into the back of Wave

JT PCB. The 5 holes that you use are marked ICSP, with an arrow pointing to the MCLR pin. Set the programmer to supply VDD of 4.9V and program the PIC.

Page 27: 19 LED Animated Christmas Star

Step 6 — Have fun! More detailed info available at Instructables and The LED Artist.

Page 28: 19 LED Animated Christmas Star

6) Running message display project for Christmas

Introduction

As Christmas is coming people have already lightened their houses. I thought of doing

something different for this Christmas besides the festive Christmas lights. I made a running message display using LEDs, and thought of sharing it with you. This is a very simple running

message display project that displays the message ‘MERRY XMAS’, where each letter is created

with 5mm diameter red-color LEDs. The 9 letters in the message are individually turned on or off through a PIC16F688 microcontroller’s I/O pins. Therefore, a variety of display patterns can be

generated through the software inside the microcontroller.

Christmas running message display

Theory

LED Math

The forward voltage of an LED depends on its type. If the LED is red, the forward voltage is usually between 1.7 – 2.1 V. For green and blue LEDs, this value is higher. An LED requires a

resistor in series to limit the current in the LED to a safe value. Most 5mm LEDs operate close to

their peak brightness at a drive current of 20 mA. In this project, I am driving my LEDs at 15 mA and they still glow pretty bright. So, all of my calculations are based for 15 mA current

through the LEDs. I measured the forward voltage across my LEDs and they are about 1.95 V.

Calculating the value of the series resistor for an LED is simple. Suppose, if you want to drive a LED through a 5 V power source, you need a resistor of value (5-1.95)V/15 mA = 203 Ω to limit

the current to 15 mA. The closest available resistor (on the higher end) is of 220 Ω.

Now, let’s see how to make display letters with LEDs. The first letter of the message (MERRY

XMAS) is shown below. 17 LEDs are used in creating the letter M. If you drive each LED through a 5V supply, you require 17 series resistors, and the current will sum up to 17×15 = 255 mA. If

you add the current requirements of other letters in the message, the net current would go up to

Page 29: 19 LED Animated Christmas Star

2 A, which is quite a bit of current and you probably need a bigger heat sink for your voltage

regulator. I didn’t want to do any of these. So I thought of doing it differently that would save me from soldering to many resistors and also lower the net current requirement of the project.

How can I do that? Yes, you are right, by using higher supply voltage.

I still have my old printer’s external power supply that has that has 3 output pins for +15 V, +32

V, and Ground, and it can deliver current up to 800 mA. I thought of connecting LEDs in series

and drive them through 32 V. This way I can connect at most 16 LEDs in series with only one current limiting resistor. So, here is how I arranged the 17 LEDs for the letter M. I can’t connect

all of them in series as that would require more than 17×1.95 = 33.15V. So I connected the first

9 LEDs in series (cathode of one is connected to the anode of other) to form a chain. The remaining 8 LEDs are used to form another chain. For the first chain, the value of the series

resistor would be,

R1 = (32.0 – 1.95 x 9) V/15 mA = 963 Ω.

I used 1 K. Similarly, for the other chain of 8 LEDs, the estimated resistor value is R2 = 1.1 K. Now let’s compute the power dissipation in the resistors. The current through R1 is (32 – 1.95 x

9)V/1K = 14.45 mA. The power dissipation is 14.45 mA x 14.45 mA x 1000 Ω = 0.21 Watts.

Similarly, R2 will dissipate 0.24 Watts. So, the resistors with power rating 1/4 Watts will work fine. Next, by connecting the two anode terminals together and two cathodes together as shown

above, completes the letter M. The anode terminal will be connected to 32 V supply and the

cathode will be connected to the collector of a NPN transistor. The base of the NPN transistor will

be driven through a PIC16F688 I/O pin with a base-current limiting resistor, whereas the emitter will be grounded. When the PIC16F688 I/O pin outputs logic high, the transistor is turned on and

all the LEDs will glow and display M. This whole process is repeated for other letters in the

message. The series resistor values will be calculated in exactly the same way by considering the number of LEDs in each of the chains formed. The table below shows the number of LEDs in

my message letters with the number of chains and the series resistors I used.

Page 30: 19 LED Animated Christmas Star

Selecting transistor

Each transistor used in this project will have to sink at most 30 mA current (for letters with two

series chains). If there is only one chain of LEDs, then it would have to sink only 15 mA. So, no

special power transistor is required. But, the selected transistor must have junction breakdown voltage higher than 32 V, for both collector-emitter and collector-base terminals. The

specification of a BC547 NPN transistor says the breakdown voltage is about 45 V, and so it is

appropriate for this project. But I experienced problem with a couple of BC547 transistors that I had to replace. They just get turned on by default without applying any voltage to its base

resistor. I don’t know the cause.

Soldering LEDs on a cardboard I didn’t solder the LEDs on a prototyping circuit board to make the letters, that would be a lot of

money. I rather took a 0.25″ cardboard and drilled holes where the legs of LEDs are inserted.

The legs are bent on the backside of the cardboard and then soldered to form a chain of LEDs.

This holds the LEDs fairly tight. In order to drill the equidistant holes, first I printed the letters with round circles on papers and sticked them on the board as shown below. The circles are 0.5″

apart.

Page 31: 19 LED Animated Christmas Star

Next, I drilled two holes inside each circle at about 4 mm distance apart so that I can insert the two legs of an LED. It’s a cardboard, so drilling was not so painful. It took me about 30 minutes

to drill holes for all 134 LEDs.

After that, I took the paper out from the cardboard and inserted the LEDs. I bent the legs of the

LEDs and soldered the appropriate terminals of adjacent LEDs to make the serial chains. I also

soldered the resistors to each anode terminals of the chains.

Page 32: 19 LED Animated Christmas Star

Circuit Diagram

The circuit diagram is very simple. I am using my PIC16F688 breadboard module as the

brain of this project. The figure below shows the pin RC0 is driving the first letter M. Rest of the letters also require similar transistor drivers that are controlled through other port pins of

PIC16F688. The +5 V supply for the PIC microcontroller is derived from the +15 V power supply

(note the printer power supply has two voltage output, +15 V and 32 V) using an LM7805

regulator IC.

Page 33: 19 LED Animated Christmas Star

PIC16F688 breadboard module inserted into the transistor driver board. The board gets +15 V

and +32 V from the printer’s power supply.

PIC16F688 module controls the switching patterns of the letters

Page 34: 19 LED Animated Christmas Star

The circuit board is fixed on the backside of the cardboard using screws.

Page 35: 19 LED Animated Christmas Star

7) LED Dancing light using PIC Microcontroller: Beginner's guide

LED running light project can be easily implemented using

microcontrollers especially with microchip PIC microcontroller. This is a simple microcontroller project using micro PIC16f877A with

circuit diagram. PIC16F877A is a 40 pin IC. LEDs are connected at

Port B; these LEDs twinkle according to the microcontroller C

program providing a dancing effect to the viewer. Mikro C compiler

is used for PIC programming. The simulation of circuit from i-

St@r lab is shown in this article. This microcontroller project

program is easy for those who wish to explore the fundamentals of

embedded microcontroller programming from the PIC

microcontroller MCU. The Mikro C is a popular C language compiler

for PIF16F8xxx family and it has wide varieties of inbuilt functions (Library functions). You can download it from the Mikro C website.

You can simply realize this program if you have done LED

interfacing with PIC microcontroller.

Microcontroller C Program void main() { TRISB=0x00; while(1) { PORTB=0x81; delay_ms(100); PORTB=0x42; delay_ms(100); PORTB=0x24; delay_ms(100); PORTB=0x18; delay_ms(100); PORTB=0x24; delay_ms(100); PORTB=0x42; delay_ms(100); } }

Page 36: 19 LED Animated Christmas Star
Page 37: 19 LED Animated Christmas Star
Page 38: 19 LED Animated Christmas Star