查看: 2801|回复: 3

转帖:音圈电机时钟

[复制链接]
  • TA的每日心情
    开心
    2014-4-21 09:44
  • 签到天数: 26 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2013-5-24 13:23:39 | 显示全部楼层 |阅读模式
    分享到:
    音圈电机时钟
    1.jpg
    码字太累直接上图
    在网上看到别人做的摇摆时钟羡慕至极!教程看的眼花缭乱!还是自己动手比较实际,十好几天做的东西
    应为噪声比较大所以打算拆了!零件用来做其他的
    继续其他的猎物!
    2.jpg
    买不到排阻就用单电阻并联的怕掉用热熔胶固定就行
    192949vx3wzik4vjgkd0nw.jpg
    开始用弹簧调了好久调不出来结果悲剧了弹簧都拉坏了后来就该用
    4.jpg
    以前的电视屏幕后面的高压包上面拆的用来做限位缓冲用
    5.jpg
    找不到合适的线来连接考虑到线太多不好看影响美观问别人要了两条排线
    额的神!天!24位1.5公分宽的排线用剪刀帮它剪下来11位而且每位都要分开1公分左右!
    我太佩服我的勇气了!居然做到了如此精密的事嘿嘿。。。
    6.jpg

    7.jpg


    最后程序奉上

    #include <reg52.h> /*硬件端口定义*/
    sbit set0=P0^1;
    sbit set1=P0^0;
    sbit set2=P0^2; sbit put1=P3^6;
    sbit put2=P3^7; /*时钟用数组*/
    unsigned char BUFFER[]={0,0,0,0};
    unsigned char maxnum[]={59,23}; /*显示用数组*/
    unsigned int v[20];
    unsigned int w[7]; /*字符字模*/
    unsigned char code ASCIIDOC[] = // ASCII
    {
    0x7C,0x8A,0x92,0xA2,0x7C,0x00, // -0-00
    0x00,0x42,0xFE,0x02,0x00,0x00, // -1-01
    0x46,0x8A,0x92,0x92,0x62,0x00, // -2-02
    0x84,0x82,0x92,0xB2,0xCC,0x00, // -3-03
    0x18,0x28,0x48,0xFE,0x08,0x00, // -4-04
    0xE4,0xA2,0xA2,0xA2,0x9C,0x00, // -5-05
    0x3C,0x52,0x92,0x92,0x8C,0x00, // -6-06
    0x80,0x8E,0x90,0xA0,0xC0,0x00, // -7-07
    0x6C,0x92,0x92,0x92,0x6C,0x00, // -8-08
    0x62,0x92,0x92,0x94,0x78,0x00, // -9-09 0x00,0x00,0x00,0x00,0x00,0x00, // - -10
    0x00,0x00,0xFA,0x00,0x00,0x00, // -!-11
    0x04,0x08,0x10,0x20,0x40,0x00, // -/-12
    0x00,0x6C,0x6C,0x00,0x00,0x00, // -:-13 0x3E,0x48,0x88,0x48,0x3E,0x00, // -A-14
    0xFE,0x92,0x92,0x92,0x6C,0x00, // -B-15
    0x7C,0x82,0x82,0x82,0x44,0x00, // -C-16
    0xFE,0x82,0x82,0x82,0x7C,0x00, // -D-17
    0xFE,0x92,0x92,0x92,0x82,0x00, // -E-18
    0xFE,0x90,0x90,0x90,0x80,0x00, // -F-19
    0x7C,0x82,0x8A,0x8A,0x4E,0x00, // -G-20
    0xFE,0x10,0x10,0x10,0xFE,0x00, // -H-21
    0x00,0x82,0xFE,0x82,0x00,0x00, // -I-22
    0x04,0x02,0x82,0xFC,0x80,0x00, // -J-23
    0xFE,0x10,0x28,0x44,0x82,0x00, // -K-24
    0xFE,0x02,0x02,0x02,0x02,0x00, // -L-25
    0xFE,0x40,0x30,0x40,0xFE,0x00, // -M-26
    0xFE,0x20,0x10,0x08,0xFE,0x00, // -N-27
    0x7C,0x82,0x82,0x82,0x7C,0x00, // -O-28
    0xFE,0x90,0x90,0x90,0x60,0x00, // -P-29
    0x7C,0x82,0x8A,0x84,0x7A,0x00, // -Q-30
    0xFE,0x90,0x98,0x94,0x62,0x00, // -R-31
    0x64,0x92,0x92,0x92,0x4C,0x00, // -S-32
    0x80,0x80,0xFE,0x80,0x80,0x00, // -T-33
    0xFC,0x02,0x02,0x02,0xFC,0x00, // -U-34
    0xF8,0x04,0x02,0x04,0xF8,0x00, // -V-35
    0xFE,0x04,0x18,0x04,0xFE,0x00, // -W-36
    0xC6,0x28,0x10,0x28,0xC6,0x00, // -X-37
    0xC0,0x20,0x1E,0x20,0xC0,0x00, // -Y-38
    0x86,0x8A,0x92,0xA2,0xC2,0x00, // -Z-39 0x24,0x2A,0x2A,0x1C,0x02,0x00, // -a-40
    0xFE,0x14,0x22,0x22,0x1C,0x00, // -b-41
    0x1C,0x22,0x22,0x22,0x10,0x00, // -c-42
    0x1C,0x22,0x22,0x14,0xFE,0x00, // -d-43
    0x1C,0x2A,0x2A,0x2A,0x10,0x00, // -e-44
    0x10,0x7E,0x90,0x90,0x40,0x00, // -f-45
    0x19,0x25,0x25,0x25,0x1E,0x00, // -g-46
    0xFE,0x10,0x20,0x20,0x1E,0x00, // -h-47
    0x00,0x00,0x9E,0x00,0x00,0x00, // -i-48
    0x00,0x01,0x11,0x9E,0x00,0x00, // -j-49
    0xFE,0x08,0x14,0x22,0x02,0x00, // -k-50
    0x00,0x82,0xFE,0x02,0x00,0x00, // -l-51
    0x1E,0x20,0x1E,0x20,0x1E,0x00, // -m-52
    0x20,0x1E,0x20,0x20,0x1E,0x00, // -n-53
    0x1C,0x22,0x22,0x22,0x1C,0x00, // -o-54
    0x3F,0x24,0x24,0x24,0x18,0x00, // -p-55
    0x18,0x24,0x24,0x24,0x3F,0x00, // -q-56
    0x20,0x1E,0x20,0x20,0x10,0x00, // -r-57
    0x12,0x2A,0x2A,0x2A,0x24,0x00, // -s-58
    0x20,0xFC,0x22,0x22,0x24,0x00, // -t-59
    0x3C,0x02,0x02,0x3C,0x02,0x00, // -u-60
    0x38,0x04,0x02,0x04,0x38,0x00, // -v-61
    0x3C,0x02,0x3C,0x02,0x3C,0x00, // -w-62
    0x22,0x14,0x08,0x14,0x22,0x00, // -x-63
    0x39,0x05,0x05,0x09,0x3E,0x00, // -y-64
    0x22,0x26,0x2A,0x32,0x22,0x00, // -z-65 }; unsigned int TZ,Ti;
    unsigned char ii,jj,nn,mm,tt, Ms; /*延时函数*/
    void DelayMs(unsigned int msec)
    {
    unsigned int x,y;
    for(x=0; x<=msec;x++)
    {
    for(y=0;y<=110;y++);
    }
    } /*键盘去抖处理函数*/
    unsigned char ChKey(bit Key)
    {
    if(Key==0){
    DelayMs(30);
    if(Key==0) return(1);
    }
    } /*定时器中断0处理(时钟)函数*/
    void timer0(void) interrupt 1 using 1
    {
    TH0=-(5000/256);
    TL0=-(5000%256);
    TR0=1;
    BUFFER[0]=BUFFER[0]+1;
    if (BUFFER[0]>201){
    BUFFER[0]=0; BUFFER[1]=BUFFER[1]+1;
    Ms=!Ms;
    if (BUFFER[1]==60){
    BUFFER[1]=0;BUFFER[2]=BUFFER[2]+1;
    if (BUFFER[2]==60){
    BUFFER[2]=0;BUFFER[3]=BUFFER[3]+1;
    if (BUFFER[3]==24) BUFFER[3]=0;
    }
    }
    }
    } /*定时器中断1处理(LED驱动)函数*/
    void timer1(void) interrupt 3 using 1
    {
    TH1=(Ti+tt*15)/256; TL1=(Ti+tt*15)%256;
    if((put1==1)&&(ii<7)&&(Ms*w[ii]==0)) P2=~ASCIIDOC[v[ii]*6+jj]; else P2=0xff;
    jj++; tt++;
    if(jj>5) {ii++; jj=0;};
    if(ii>10) {ii=0;put1=~put1; put2=~put2;tt=0;}
    } /*主程序*/
    void main(void)
    {
    Ms=1;
    Ti=-2100; //根据实际调整
    mm=14;
    put1=0;put2=1;
    /*初始化定时中断0*/
    TMOD=0x11;
    TH0=-5000/256; TL0=-5000%256;
    TR0=1;ET0=1;
    /*初始化定时中断1*/
    TH1=Ti/256; TL1=Ti%256;
    TR1=1;ET1=1; /* 七个显示位置,中间为":" 符 */
    v[0]=10;
    v[1]=10;
    v[2]=10;
    v[3]=13;
    v[4]=10;
    v[5]=10;
    v[6]=10;

    /*正常运行状态,让中间":"符闪现*/
    w[1]=0;
    w[2]=0;
    w[3]=1;
    w[4]=0;
    w[5]=0;

    /*摇摆棒初始启动*/
    do {
    mm--;
    DelayMs(120+mm*5);
    put1=~put1; put2=~put2;
    }while(mm>0); /*启动显示*/
    ii=0;jj=0;
    EA=1; /*正式运行*/
    for(;;){
    while(1){
    /*显示时和分*/
    v[1]=BUFFER[3]/10;
    v[2]=BUFFER[3]-v[1]*10;
    v[4]=BUFFER[2]/10;
    v[5]=BUFFER[2]-v[4]*10; /*按键处理*/
    if(ChKey(set0)==1){ //调整项键
    if(TZ<2) TZ++; else TZ=0;
    /*闪现调整项*/
    switch(TZ){
    case 0:w[1]=0;w[2]=0;w[3]=1;w[4]=0;w[5]=0;break;//正常时秒闪
    case 1:w[1]=0;w[2]=0;w[3]=0;w[4]=1;w[5]=1;break;//调分时分闪
    case 2:w[1]=1;w[2]=1;w[3]=0;w[4]=0;w[5]=0;break;//调时时时闪
    }
    };
    DelayMs(300);
    if(ChKey(set1)==1){ if(BUFFER[TZ+1]<maxnum[TZ-1]) BUFFER[TZ+1]++;
    else BUFFER[TZ+1]=0;DelayMs(300);};
    // 加法键
    if(ChKey(set2)==1){ if(BUFFER[TZ+1]>0) BUFFER[TZ+1]--;
    else BUFFER[TZ+1]=maxnum[TZ-1];DelayMs(300);};
    // 减法键
    DelayMs(300);
    }
    }
    }

    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2014-7-16 09:10
  • 签到天数: 361 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2013-5-24 14:10:37 | 显示全部楼层
    楼主辛苦了。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2019-4-25 10:29
  • 签到天数: 724 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2013-5-29 22:19:59 | 显示全部楼层
    收藏了,谢谢楼主的分享~
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2017-8-10 17:40
  • 签到天数: 641 天

    连续签到: 2 天

    [LV.9]以坛为家II

    发表于 2014-2-14 08:28:12 | 显示全部楼层
    楼主这是怎么做的?供电用无线吗?
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-12-25 10:33 , Processed in 0.208624 second(s), 23 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.