⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wtv020-sd-16˴ʶ-

📁 WTV020-SD-16语音模块msp430f149c程序
💻
字号:
#include <msp430x14x.h>
#define KEY (P2IN&BIT4)
#define KEY1 (P2IN&BIT3)
#define yuyin_0 P2OUT &= ~BIT2
#define yuyin_1 P2OUT |= BIT2
#define yuscl_0 P2OUT &= ~BIT1
#define yuscl_1 P2OUT |= BIT1
#define yurst_0 P2OUT &= ~BIT0
#define yurst_1 P2OUT |= BIT0
//************************************************************************ 
#define CPU_F ((double)8000000) 
#define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0)) 
#define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0)) 
#define MANG (P3IN&BIT7)
//************************************************************************
unsigned int FD=0x0000;
unsigned int FD1=0xFFF0;
unsigned char h2[10]; 
typedef unsigned char uchar;
typedef unsigned int uint;
//第2行显示数据
uchar times[7];	//顺序:秒,分,时,日,月,星期,年;格式:BCD
uchar addyy[]={0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,
               0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f/* 15*/,0x0010/* 16*/,
      0x0011/* 17*/,0x0012/* 18*/,0x0013/* 19*/,0x0014/* 20*/,0x0015/* 21*/,0x0016/* 22*/,
      0x0017/* 23*/,0x0018/* 30*/,0x0019/* 40*/,0x001a/* 50*/, 0x001b/* 点*/,0x001c/* 分*/,
      0x001d/* 年*/,0x001e/* 月*/,0x001f/* 日*/,0x0020/* 度*/,0x0021/* 凌晨*/,0x0022/* 摄氏度*/,
      0x0023/* 灯泡已坏*/,0x0024/* 灯前无人*/,0x0025/* 现在时间*/,0x0026/* 请注意坐姿*/,0x0027/* 秒*/
               };
//****************************定义全局变量

void ini_yuyin(void)  //语音初始化
{
 yurst_0;
 delay_ms(5);        
 yurst_1; 
}


void  Send_twolines(uint addr) //二线发码子程序
   {
        unsigned char i;
          yurst_0;
          delay_ms(5);        
          yurst_1;
    	  yuscl_1;               
    	  delay_ms(5);         /* 5ms*/ 
           yuscl_0; 
    	  delay_ms(2);
   	  for(i=0;i<16;i++) 
     	  {
          yuscl_0; 
      	  if(addr&0X8000)
           yuyin_1; 
      	  else 
           yuyin_0; 
      	  addr<<=1; 
      	  delay_us(250);  /* 100us */ 
      	  yuscl_1; 
      	  delay_us(250);  
      	  } 
     	  yuscl_1; 
          yuyin_1;
   }
  void baoshi(void)
{
  uchar m;
  Send_twolines(addyy[37]);
  delay_ms(2000);
//  while(MANG==BIT7);
  if(times[2]<10) m=times[2];
  if(times[2]>15&&times[2]<=25) m=times[2]-6;
  if(times[2]>25) m=times[2]-12;
    Send_twolines(addyy[m]);
    delay_ms(1500);
 //while(MANG==BIT7);
  
  Send_twolines(addyy[27]);
    delay_ms(1000);
     //while(MANG==BIT7);
   if((times[1]>>4)==0)
   {
     Send_twolines(addyy[0]);
     delay_ms(1000);
    if((times[1]&0x0f)>0) 
    {
    Send_twolines(addyy[times[1]&0x0f]);
      delay_ms(1500);
    }
   }
      if((times[1]>>4)==1)
      {
        Send_twolines(addyy[10+(times[1]&0x0f)]);
       delay_ms(1000);
     }
      if((times[1]>>4)==2)
      {
        Send_twolines(addyy[20]);
           delay_ms(1500);
        if((times[1]&0x0f)>0) 
         {
        Send_twolines(addyy[times[1]&0x0f]);
        delay_ms(1000);
         }
      }
        if((times[1]>>4)==3)
      {
        Send_twolines(addyy[24]);
           delay_ms(1000);
            if((times[1]&0x0f)>0) 
            {
            Send_twolines(addyy[times[1]&0x0f]);
              delay_ms(1500);
            }

      }
       if((times[1]>>4)==4)
      {
        Send_twolines(addyy[25]);
           delay_ms(1000);
        if((times[1]&0x0f)>0) 
            {
            Send_twolines(addyy[times[1]&0x0f]);
              delay_ms(1500);
            }
      }
     if((times[1]>>4)==5)
      {
        Send_twolines(addyy[26]);
        delay_ms(1000);
        if((times[1]&0x0f)>0) 
        {
        Send_twolines(addyy[times[1]&0x0f]);
          delay_ms(1800);                                                                                                     
        }
     }
   Send_twolines(addyy[28]);
     delay_ms(1000);     
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -