MCU + JQ6500 voice module usage code

Publisher:电竞狂人Latest update time:2020-01-31 Source: 51heiKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I was bored and made some fun stuff at home recently. I needed a module to drive a speaker to play a reminder sound. I initially bought the WT588DM01 because it came with 8M Flash and was worry-free. But it turned out that I had to buy a programmer worth more than 30 dollars to use it.


Later, I gritted my teeth and bought a JQ6500 voice module. I could burn MP3 files into it by plugging it into a computer via USB. It turned out that Shenzhen manufacturers had a good insight into the needs.


I bought it, but the information provided by the manufacturer was divided into three versions. The PCB appearance was changed, but the PDF was not updated. I had to tinker with it myself and try it out with a 51 according to the reference materials.

51hei screenshot_20200130165511.png 

This is the external view of the module in the PDF. The actual product you bought looks like this:

51hei screenshot_20200130165628.png 

The chip has 24 pins and the module has 16 pins. The 16 pins have not changed, but there are slight changes on the module PCB board, but it does not affect the direct use of the 16 pins led out of the module.

51hei screenshot_20200130165417.png 

Module wiring schematic diagram, SPK+ and SPK- can be directly connected to a passive buzzer.


The microcontroller source program is as follows:

#include //header file

#include

/*

The ninth pin of this module, which is the RX pin, is connected to P3^1 of the microcontroller.

The tenth pin, also known as the TX pin, is connected to P3^0 of the microcontroller (if you do not process the data returned by this module, you can leave it unconnected)

At the same time, the module and the microcontroller must share the same ground and connect GND

The module can also be powered directly by the power supply on the microcontroller.

*/


typedef unsigned char uint8;

typedef unsigned int uint16;

sbit KEY1=P3^2; //First key

sbit KEY2=P3^3; // First song loop key

sbit KEY3=P3^4; //Pause key

sbit KEY4=P3^5; //Enter sleep mode



uint8 First[]={0x7E,0x04,0x03,0x00,0X01,0xEF}; //First song instruction

uint8 Next[]={0x7E,0x03,0x11,0x01,0xEF}; // First loop

uint8 Add[]={0x7E ,0x02, 0x0E, 0xEF}; // 0x0e pause

uint8 Sub[]={0x7E, 0x02, 0x0A, 0xEF}; // 0x0a enters sleep


void delay150ms(void) //error -0.000000000047us

{

    unsigned char a,b,c;

    for(c=6;c>0;c--)

        for(b=52;b>0;b--)

            for(a=220;a>0;a--);

    _nop_(); //if Keil,require use intrins.h

}





/*

* UART initialization

* Baud rate: 9600

*/

void UART_init(void)

{

    SCON = 0x50; // 10-bit uart, allow serial reception


    TMOD = 0x20; // Timer 1 works in mode 2 (auto reload) 0010 0000

    TH1 = 0xFD;

    TL1 = 0xFD; //Set the baud rate to 9600


    TR1 = 1;

}


/*

* UART sends one byte

The data type of the input parameter uint8 is the data to be sent

*/

void UART_send_byte(uint8 dat)

{

        SBUF = dat;

        while (TI == 0);

        TI = 0;

}


/*

* UART sends string 

  The first parameter is the address of the string or data to be sent.

  The second parameter is the length of the data or string to be sent

*/

void UART_send_string(uint8 *buf,uint8 len)

{ uint8 i;

        for(i=0;i                UART_send_byte(*buf++);

}


main()

{

        UART_init(); //Serial port initialization

        

        while (1) //A large loop that keeps detecting key presses and sending commands

        { if(KEY1==0) //If the first key is pressed, play the first segment


    { while(!KEY1); //Wait for the key to be released

                         UART_send_string(First,6);

    }                

                else if(KEY2==0) //If the second button is pressed, loop the first song


    { while(!KEY2); //Wait for the key to be released

                         UART_send_string(Next,5);

                         delay150ms(); //After testing, a delay of 150ms between two instructions works best

                         UART_send_string(First,6);

    }                

                else if(KEY3==0) //If the third button is pressed, pause the playback

                        { while(!KEY3); //Wait for the key to be released

                         UART_send_string(Add,4);

    }        

else if(KEY4==0) //If the fourth button is pressed, enter sleep mode


    { while(!KEY4); //Wait for the key to be released

                         UART_send_string(Sub,4);

    }                        

        }


}


Four buttons and a serial port are used. Every time a button is detected, the microcontroller sends a serial port command to the module JQ6500. The time between two commands should be no less than 150ms (actual measurement), otherwise there will be no response.

Keywords:MCU Reference address:MCU + JQ6500 voice module usage code

Previous article:Jump Jump game source program based on 51 single chip microcomputer
Next article:A learning infrared remote control switch program was made using the STc15f104e microcontroller

Recommended ReadingLatest update time:2024-11-15 13:28

Single chip simple stopwatch C51 program
Download the schematic used in this program:  click here  . The microcontroller chip used is stc89c52; just find the schematic diagram of the digital tube. This is the circuit diagram of the entire microcontroller development board. Ignore the others. The following is the program source code: /** *Project: Simple St
[Microcontroller]
51 MCU Tutorial (IV): Independent-Matrix Keyboard Application and Design
Introduction: The previous lecture introduced and applied the serial port communication of the microcontroller, and gave examples. From this lecture, the peripheral circuits of the microcontroller will be introduced. This lecture introduces the circuit of the microcontroller external keyboard. Through this lecture, re
[Microcontroller]
51 MCU Tutorial (IV): Independent-Matrix Keyboard Application and Design
Freescale MCU PIT Assembly Programming (I)
Freescale MCU (XS128 series) MCU Assembly Programming (I) I am a novice, and I learned assembly programming from a novice; assembly is not as complicated and difficult to understand as imagined, and it is quite interesting to savor it carefully. Just treat it as a hobby, and learn assembly (this has always been a bi
[Microcontroller]
Application of STC MCU Expanding P4 Port
      For the STC89 series microcontrollers in PQFP-44 and PLCC-44 packages, 4 I/O ports P4 are added. The address of P4 port in the special function register is E8H, which can be bit addressed. Users need to define the address before using P4 port, and then operate P4 port like other I/O ports.       In addition, P4
[Microcontroller]
Analysis of the main functions of STM8 MCU interrupts
Internal interrupts: usually caused by hardware errors or errors during operation, which are generally unavoidable; External interrupt: It is an interrupt request issued by the processor's peripherals, such as timer interrupt, UART receive interrupt, and external interrupts can generally be shielded by the interrupt c
[Microcontroller]
Analysis of the main functions of STM8 MCU interrupts
Design of electronic locker system based on 51 single chip microcomputer
Circuit Description: Security is the most important concern in our daily life. Everyone feels that security is very important, and the door and security at home can be as safe as possible. In order to ensure the safety of the door access Therefore, we intend to improve security by introducing an electronic combinati
[Microcontroller]
Design of electronic locker system based on 51 single chip microcomputer
51 MCU Experiment 17: LCD1602 Liquid Crystal
The circuit diagram of the development board LCD module is as follows: #include reg52.h #include lcd.h   uc dig1 =" Happy New Year "; uc dig2 =" Ha  Ha  Ha  Ha ";   void main() { uc i; lcdinit(); lcdwritecom(0x80); for(i=1;i =16;i++) { lcdwritedata(dig1 ); }     lcdwritecom(0xc0); for(i=1;i =16;i++) { lc
[Microcontroller]
51 MCU Experiment 17: LCD1602 Liquid Crystal
51 single chip microcomputer dot matrix experiment
1. Circuit diagram analysis 1.1 Dot matrix experiment diagram P0 controls all rows, and P0 outputs low level and is effective; 74hc595 output controls all columns, and outputs high level and is effective. Let the port of P0^7 be low level, and the other ports of P0 be high level; if the port of D7 is high level,
[Microcontroller]
51 single chip microcomputer dot matrix experiment
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号