Hello~all,thank you for taking time to read my post firstly.
I made a rotating digital clock on a sudden impluse.Here I can’t wait to share my pleasure and experience to you.Hoping that it can bring some help to you.
At first,I found a cardboard to be the dial plate and draw the site of light emitting diodes by using com-passes.Then I took the light emitting diodes to the cardboard and connected power lines. The entire dial plate was finished ! What’s more ,in order to recognize the time state in the evening,I add red LEDs every five LEDs. In order to improve the appearance, I found a beautiful box of chocolate to be the outer skin. The line is built on a universal board and connected by flexible conductor. The reason it is named “rotating digital clock” is that it connected the LEDs on a ring forming,The LED removes a seat every seconds. In addition, the digital shows of clock is charged by figure so that the number of LEDs and the complexity of line can be saved.
The design includes the buildings of hardware and the programming design of software.Please look at the following picture:
I used DS1302 to be the timing core in the system, I myself think that this chip--DS1302 has a good quality and is very suitable here.This is DS1302’s datasheet: http://www.kynix.com/uploadfiles/pdf8827/DS1302S.pdf.
Next.I dispose the writing and reading program for DS1302.This is the programming code:
- // DS1302写入函数, 向DS1302的指定地址写入一个字节的数据 。
- void write_ds1302(uchar cmd,uchar indata)
- {
- sclk=0;
- reset=1;
- write_byte(cmd);
- write_byte(indata);
- sclk=0;
- reset=0;
- }
- // DS1302读取函数, 从DS1302的指定地址读取一个字节的数据。
- uchar read_ds1302(uchar addr)
- {
- uchar backdata;
- sclk=0;
- reset=1;
- write_byte(addr); //先写地址
- backdata=read_byte(); //然后读数据
- sclk=0;
- reset=0;
- return (backdata);
- }
- //读取时间函数,负责读取当前时间,并将读取的时间转换为10进制数
- void get_time()
- {
- uchar sec,min,hour; //定义秒、分和小时变量
- write_ds1302(0x8e,0x00); //控制命令,WP=0,允许写操作
- write_ds1302(0x90,0xa0); //涓流充电控制
- sec=read_ds1302(0x81); //读取秒
- min=read_ds1302(0x83); //读取分
- hour=read_ds1302(0x85); //读取时
- time_buf[0]=sec/16*10+sec%16; //将读取到的16进制数转化为10进制
- time_buf[1]=min/16*10+min%16; //将读取到的16进制数转化为10进制
- time_buf[2]=hour/16*10+hour%16; //将读取到的16进制数转化为10进制
- }
Finally, the quad digital tube was used to be the showing component driving by transistor--9012.
I’m so happy that It has a good effective at the final!
PS: No only my clock has a function of dual alarm clock instructing by LED,but also the time correction function. Beside,the current is supplied by regulated power which is benefit to green environment protection.