找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1449|回复: 1
打印 上一主题 下一主题
收起左侧

单片机的isd4004录放机制作程序

[复制链接]
跳转到指定楼层
楼主
ID:438436 发表于 2018-12-3 15:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
单片机源程序如下:
  1. #include<reg52.h>
  2. #include<intrins.h>
  3. #include<LCD1602.h>
  4. sbit SS=P1^0;
  5. sbit MOSI=P1^1;
  6. sbit SCLK=P1^2;
  7. sbit INT=P1^3;
  8. sbit Rec=P1^4;
  9. sbit Play=P1^5;
  10. sbit Stop=P1^6;
  11. sbit Shut=P1^7;
  12. sbit RecLight=p2^5;
  13. sbit PlayLight=p2^6;
  14. sbit WorkLight=P2^7;
  15. unsigned int n;
  16. unsigned char count;
  17. unsigned char code
  18. POWERUP=0x20,SETPLAY=0xE0,PLAY=0xF0,SETREC=0xA0,REC=0xB0,SETMC=0xE8,MC=0xF8,STOP=0x30,STOPPOWER=0x10;
  19. unsigned char code speed[]={"speed:"};
  20. unsigned char code tab[]={"0123456789"};
  21. void dingshiqi() interrupt 1
  22. {
  23.    TH0=0x4c;
  24.         TL0=0x00;
  25.         n++;
  26.         }
  27. void display()
  28. {
  29. unsigned char i,count_ge,count_shi,count_bai;
  30. count=TH1*0X10*0X10+TL1;
  31. count_ge=(unsigned char)(count%10);
  32. count_shi=(unsigned char)((count%100)/10);
  33. count_bai=(unsigned char)(count/100);
  34. write_com(0x80);
  35. for(i=0;i<6;i++)
  36.   {
  37.    write_dat(speed[i]);
  38.         }
  39. write_dat(tab[count_bai]);
  40. write_dat(tab[count_shi]);
  41. wirte_dat(tab[count_ge]);
  42. write_dat('r');
  43. TH1=0;
  44. TL1=0;
  45. n=0;
  46. }
  47. void delay(unsigned int i)
  48. {
  49. while(i--);
  50. }
  51. void Command(unsigned char command,unsigned int address)
  52. {
  53.   unsigned char i,j;
  54.   SS=1;
  55.   SCLK=0;
  56.   SS=0;
  57.   if(address!=0)
  58.   {
  59.    SS=1;
  60.         SCLK=0;
  61.         SS=0;
  62.         for(i=0;i<16;i++)
  63.         {
  64.          address=_cror_(address,1);
  65.          j=address<<1;
  66.          MOSI=CY;
  67.          SCLK=0;
  68.          delay(3);
  69.          SCLK=1;
  70.          }
  71.   }
  72.   for(i=0;i<8,i++)
  73.    {
  74.          command=_cror_(command,1);
  75.          j=command<<1;
  76.          MOSI=CY;
  77.          SCLK=0;
  78.          delay(3);
  79.          SCLK=1;
  80.          }
  81.          SS=1;
  82.          }
  83. void main()
  84. {
  85.   unsigned char a=1:
  86.   P1=0xFF;
  87.   P0=0xFF;
  88.   INT=1;
  89.   lcd_init();
  90.   EA=1;
  91.   ET0=1;
  92.   ET1=1;
  93.   TMOD=0x51;
  94.   TH1=0;
  95.   TL1=0;
  96.   TH0=0x4c;
  97.   TL0=0x00;
  98.   TR0=1;
  99.   TR1=1;
  100.   while(1)
  101.   {
  102.     while(Rec==0)
  103.          {
  104.           delay(3000);
  105.           while (Rec==0)
  106.      {
  107.            RecLight=0;
  108.                 PlayLight=1;
  109.                 WorkLight=0;
  110.                 Command(POWERUP,0);
  111.                 delay(6000);
  112.                 Command(POWERUP,0);
  113.                 delay(6000);
  114.                 delay(6000);
  115.                 Command(SETREC,0x05);
  116.                 Command(REC,0);
  117.                 break;
  118.                 }
  119.            while (Rec==0){};
  120.                 }
  121.           while(Play==0)
  122.                 {
  123.                  delay(3000);
  124.                  while(Play==0)
  125.                  {
  126.                   PlayLight=0;
  127.                   RecLight=1;
  128.                   WorkLight=0;
  129.                   Command(POWERUP,0);
  130.                   delay(6000);
  131.                   Command(POWERUP,0);
  132.                   delay(6000);
  133.                   delay(6000);
  134.                   Command(SETPLAY,0x05);
  135.                   Command(PLAY,0);
  136.                   break;
  137.                   }
  138.                   while(Play==0){};
  139.                   }
  140.           while{Stop==0||INT==0)
  141.                  {
  142.                   delay(3000);
  143.                   while(Stop==0||INT==0)
  144.                   {
  145.                    PlayLight=1;
  146.                         RecLight=1;
  147.                         Command(Stop,0);
  148.                         a=1;
  149.                         break;
  150.                         }
  151.                         while (Stop==0){};
  152.                         }
  153.           while{Shut==0}
  154.            {
  155.                  delay(3000);
  156.                  while (Shut==0)
  157.                  {
  158.                   PlayLight=1;
  159.                   RecLight=1;
  160.                   WorkLight=1;
  161.                   Command(STOPPOWER,0)
  162.                   break;
  163.                   }
  164.                   while(Shut==0){};
  165.                   }
  166.                  if(n==20) display();
  167.                  if(count>40&&a==1)
  168.                   {
  169.                    PlayLight=0;
  170.                    RecLight=1;
  171.                    WorkLight=0;
  172.                    Command(POWERUP,0)
  173.                    delay(6000);
  174.                    Command(POWERUP,0)
  175.                    delay(6000);
  176.                    delay(6000);
  177.                    Command(SETPLAY,0x05);
  178.                    Command(PLAY,0);
  179.                    a=0;
  180.                    }
  181.                 }
  182. }
复制代码

所有资料51hei提供下载:
dpj.rar (6.17 KB, 下载次数: 12)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1 发表于 2018-12-4 04:27 | 只看该作者
补全原理图或者详细说明一下电路连接即可获得100+黑币
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表