What is being used now WTN Voice chip , It is widely used , In order to facilitate its operation , Create a yuyin class , The data member part includes statement data , Command data and volume data , The statement data has been burned into the voice chip in advance . The operations that can be performed by member functions in a class are :1, Specifies which statement data to play
  2, Adjust the volume  3,, Change the playback mode of the statement .

class  yuyin

{  

}

Yuyin.h file

#ifndef YUYIN_H_
#define YUYIN_H_
#include <stdio.h>
#define YUYIN_xunhuandangqiang   0xF2
#define YUYIN_lianmabofang       0xF3
#define YUYIN_charujinyin        0xF8
#define YUYIN_tingzhidangqian   0xFE

class  Yuyin
{  
private: 
int yuju_n; 
int yinliang_n ; 
byte P_DATA;
 char   yuju[225];
 char   yinliang[16];

public:

Yuyin(int n ,byte pin , byte PinMode);
~Yuyin();

  void  writedata(  char SB_DATA) ;    
 void tiaodayinliang();                 
void  tiaoxiaoyinliang();               
void bofangyuju(int yuju_i);           
void bofangmoshi(int  moshi_i);   

};
#endif

Yuyin.cpp file

#if ARDUINO >= 100 
  
#include "Arduino.h"

#else
  
#include "WProgram.h"

#endif

#include "Yuyin.h"

Yuyin::Yuyin(int n, byte m)
{

 pinMode(pin, PinMode); 
    yuju_n=n;
    P_DATA=m;
   yinliang_n=15;
   yuju[ 225]={0X00,0X01,0X02};
   mingling[4]={0XF2,0XFE,0XF3,0XF8};
 
 yinliang[16]={0XE0,0XE1,0XE2,0XE3,0XE4,0XE5,0XE6,0XE7,0XE8,0XE9,0XEa,0XEb,0XEc,0XEd,0XEe,0XEf};

}

Yuyin::~Yuyin()

Yuyin:: writedata( char SB_DATA)
{
unsigned char S_DATA;
boolean  B_DATA;
S_DATA = SB_DATA;
digitalWrite(P_DATA,LOW);
delay(5); 
B_DATA = S_DATA&0X01;
for(int j=0;j<8;j++)
{
if(B_DATA == true)
{
digitalWrite(P_DATA,HIGH);
delayMicroseconds(600);
digitalWrite(P_DATA,LOW);
delayMicroseconds(200); 
}
else
{
digitalWrite(P_DATA,HIGH);
delayMicroseconds(200); 
digitalWrite(P_DATA,LOW);
delayMicroseconds(600);
}
S_DATA = (S_DATA>>1);
B_DATA = S_DATA&0X01;
}
digitalWrite(P_DATA,HIGH);
}

Yuyin::tiaoxiaoyinliang()

{
    if(yinliang_n>0)
    {
     yinliang_n --;
     writedata(yinliang[yinliang_n]);
    }
    else
    yinliang_n=0;

}

Yuyin::tiaodayinliang()
{
    if(yinliang_n<15)
    {
     yinliang_n++;
     writedata(yinliang[yinliang_n]);
    }
    else
    yinliang_n=15;

}

Yuyin::bofangyuju(int yuju_i)
{
    if(0<=yuju_i<=yuju_n)
     writedata(yuju[yuju_i]);
    else if(yuju_i<0)
     writedata(yuju[0]);
    else (yuju_i>yuju_n)
     writedata(yuju[yuju_n]);

}

Yuyin::bofangmoshi(int  moshi_i)
{
if(moshi_i==YUYIN_xunhuandangqiang)
     writedata(YUYIN_xunhuandangqiang);
    else if(moshi_i==YUYIN_lianmabofang)
     writedata(YUYIN_lianmabofang);
    else if(moshi_i==YUYIN_charujinyin)
     writedata(YUYIN_charujinyin);
    else (moshi_i==YUYIN_tingzhidangqian)
     writedata(YUYIN_tingzhidangqian);
}

Technology
©2019-2020 Toolsou All rights reserved,
el-select At the same time label and value value Three.js - OrbitControls Orbit control around target target parameter Fiddler Simulate request sending and modifying response data rk3399_android7.1 debugging USB Summary of Bluetooth module Centos7 lower mysql8.0 To install and change the initial password ; Summary of artificial intelligence algorithm python in switch_to_alert Usage of Keras Summary of training data loading about Bellman-Ford Personal understanding of algorithms Maximum security risk of cloud computing : Unclear safety responsibility