DIY Swing LED Clock-schematic diagram+Program

The fashion LED swing clock is popular in market which is very special and novel.The thought to make a one by myself appears in my mind when I am researching MCU now.Just a running light, I do not think it is difficult and I want to make it. So, a MCU project begins. But when I really start, I find it is not that easy as I imagined before, because there is no any ready-made material. What’s more,there exists many problems about machinery, electronics and program and all those problems should be solved by myself. After modifying and debugging time and time again during more than 20 days, the work finally finished and meet the demand basically.

Do you want to show your DIY and want to share your great idea with others?
Or you have many problems about electronics that need to be solved.
Our purpose is to help you to learn more about electronics.
If you have any question, please visit our BBS:

Now share the material of making process with DIY enthusiasts.
1.Overall plan
This project is based on the principle of persistency of vision and let a row of eight LED to do the reciprocating motion.It can display eight characters on the screen and can also display numbers or English characters.When starting up, it will display “welcome”( see picture 1) and then display the state of clock. On the scree will display the information of hour, minute, and second which separated by “:”

picture1 : boot screen picture 2: operating condition

There are three kinds of display status:1.normal operation, 2.adjust minutes 3. Adjust hours. When in the adjustment situation, the characters you need to adjust will flash for you to distinguish. So there three adjustment button:1.status key 2.addition key 3.Subtraction key(see picture3)

Picture 3: the place of buttons picture 4:Voice coil motor components
The drive part of swing stick uses the voice coil motor which is taken down from the waste hard disk. And the drive uses DC motor drive way.
As to the structure, install the voice coil motor on the universal board and then combine the sides of the universal board to a transparent organic plate with four bolts

Picture 5: the base made up of universal board and
2.Organic board picture6:side of the base
Key points of actual operation
1.The structure layout of main board(see picture7)

Picture 7(the layout of main board) picture8(LED on swing stick)
Weld LED: weld the two pins of LED on the both ends of circuit bord and let the LED closely be arranged together.
Connect the LED on swing stick to the signal of main board with flexible flat cable.The voice coil motor needs 2 and LED signal transmission needs 9, so it needs 11 flat cables at least.

Picture 9(flat cable and tension spring) picture10(tension spring)
4. In order to keep the balance of the swing stick, it needs to add two tension springs on the ends of swing stick which is close to the axis of rotation.The specification of these two tension springs should be the same and elasticity should be moderate.It is better to find different kinds of specification to try.
5.Use the way to drive DC motor to move forward or reverse and then drive the voice coil motor to move back and forth.There are many ways to make motor to move forward and reverse and the typical one is the H bridge circuit. See picture 11the H bridge circuit principle. Normally, it will use triode to replace the swith in the picture.

Picture 11 : The principle of H bridge drive
In order to simplify the circuit, it is better to use the integrated circuit of H bridge function. There are many IC, such as TA7257, TA8429H, L6203 and so on. This is M54544A of Mitsubishi(see picture 12) The definition of IC pins(see picture 13)

Picture12( motor drive IC)

Picture13( The definition of pins of M56544AL)
The schematic diagram(see picture 14)

Picture 14( schematic diagram)
The complete plan(see picture 15)

Picture 15(complete plan)
Software Design
1.The star-up of swing stick
In order to let the swing stick transit from static condition to the normal operating condition,you should add a starting procedure before real display.The essence is to speed up the frequency of drive gradually and till the stick swing regularly. You can realize it by the following code.

do {
put1=~put1; put2=~put2;
Delay(20); (this delay value determined by the actual situation)

2.The realization of second flash:the flash of number or character is realized by the variate Ms and array w. If you need the forth of the among the eight characters,the w[3]=1.The global variable Ms changes the condition?0 or1?in the function void timer0(void) and open or close to display.

if(Ms*w[ii-3]==1) P2=0xff; else P2=~ASCIIDOC[v[ii]6+jj]; //positive display
w[10-ii]==1) P2=0xff; else P2=~ASCIIDOC[v[13-ii]*6+5-jj]; // reverse display
When debugging ,I find that the width of characters on the screen is not the same(see picture 16).After analyzing, it is because that the swing stick is under force when move and the force is changing all the time. In order to adjust precisely and conveniently, I specially make a display interruption table Tr to change the time of LED display and coordinate display.

Picture 16isplay before adjustment
The program to avoid shaking of key

To avoid shaking of the key is realized by the software programming. When find that the key interface appears low level and then test after a while, if it is still low level, the result proves to be valid,otherwise to be invalid.The specific program is realized by the unsigned char ChKey(bit Key).

synchronous display

Because there is no position sensor, synchronous display depends on the clock interrupt.Then the problem appears,when the signal of voice coil motor changes , the display will sustain in the medium and guarantee the positive display to coincide with the reverse display.According to the actual observation,in order to let the signal of voice coil motor display in the medium, it needs to adjust fine and determined by the variable in the program.

The complete C51 program code
See attachment
Debug method
Although it is a mechanical and electrical integration project, the procedures of debug is not difficult .
The adjustment of mechanical parts is mainly about two tension springs.You should try best to ensure that the force of both sides should be the same and the swing stick should keep in the vertical place in static state.
1.The software part.You should delete the “Ti=-Tr[ii6+jj];”in function void timer1(void) and try to let TI get a constant value(almost 2000).You should look the range of the swing stick until you are satisfied with it.Maybe the positive display does not coincide with the reverse display.And then change other value of Ta between 42 and 50 until these two display coincide. The last step is to adjust the inhomogeneity of display. Next , recover the program of “Ti=-Tr[ii6+jj];” and try to change the value of element of the array in Tr table and ensure the average of the element in the table is the Ti value at the beginning and the width of every display character is the same.

The circuit of this project is very easy and the essence of principle is the LED watering lights, what’s more, it is very easy to find the voice coil motor. It is very suitable for the MCU enthusiasts at the beginning period.There are something that can be improved:
1.Add the clock IC which will display more precise and have no need to worry about power down
2.Add position sensor which will improve the stability of display
3.Add function of remote control which will make the adjustment more convenient.