当前位置: 首页 > news >正文

JQ6500语音模块详解(STM32)

目录

一、介绍

二、传感器原理

1.原理图

2.引脚描述

三、程序设计

main文件

usart.h文件

usart.c文件

四、实验效果 

五、资料获取

项目分享


一、介绍

        JQ6500是一种支持串口驱动的语音模块,提供串口的MP3芯片,集成了MP3WMV的硬解码。同时软件支持TF卡驱动,支持电脑直接更新SPI Flash的内容,支持FAT16、FAT32文件系统。通过简单的串口指令即可完成播放指定的音乐,以及如何播放音乐等功能,使用方便,稳定可靠。

以下是JQ6500语音模块的参数:

型号

JQ6500

工作电压

3.3~5V

额定电流

20mA

UART接口

标准串口,TTL电平,波特率可设

工作温度

-40~80

湿度

5%~95%

哔哩哔哩视频链接:

JQ6500语音模块(STM32)

(资料分享见文末) 

二、传感器原理

1.原理图

2.引脚描述

三、程序设计

1.使用STM32F103C8T6使用JQ6500语音模块连接扬声器,通过按键控制播放几段音频。

KEY

PA0

JQ6500_TX

PA10

JQ6500_RX

PA9

OLED_SCL

PB11

OLED_SDA

PB10

main文件

#include "stm32f10x.h"
#include "led.h"
#include "usart.h"
#include "delay.h"
#include "oled.h"
#include "key.h"/*****************辰哥单片机设计******************STM32* 项目			:	JQ6500语音模块实验                     * 版本			: V1.0* 日期			: 2025.2.7* MCU			:	STM32F103C8T6* 接口			:	参看usart.h						* BILIBILI	:	辰哥单片机设计* CSDN			:	辰哥单片机设计* 作者			:	辰哥 **********************BEGIN***********************/int key = 0;
int key_state = 0;
int key_num = 0;int main(void)
{ SystemInit();//配置系统时钟为72M	delay_init(72);LED_Init();LED_On();USART1_Config();//串口初始化Key_Init();OLED_Init();printf("Start \n");delay_ms(1000);OLED_Clear();//显示“语音序号:”OLED_ShowChinese(0,0,0,16,1);OLED_ShowChinese(16,0,1,16,1);OLED_ShowChinese(32,0,2,16,1);OLED_ShowChinese(48,0,3,16,1);OLED_ShowChar(64,0,':',16,1);while (1){key = Key_GetData();if(key){key_state = 1;key_num++;if(key_num>3)key_num=1;}elsekey_state = 0;if(key_state){switch(key_num){case 1:music_play(1);LED_Toggle();OLED_ShowNum(56,30,1,1,16,1);		//1break;case 2:music_play(2);LED_Toggle();OLED_ShowNum(56,30,2,1,16,1);		//2break;case 3:music_play(3);LED_Toggle();OLED_ShowNum(56,30,3,1,16,1);		//3break;default:break;}	}}
}

usart.h文件

#ifndef __USART1_H
#define	__USART1_H#include "stm32f10x.h"
#include <stdio.h>/*****************辰哥单片机设计******************STM32* 项目			:	JQ6500语音模块实验                     * 版本			: V1.0* 日期			: 2025.2.7* MCU			:	STM32F103C8T6* 接口			:	参串口1						* BILIBILI	:	辰哥单片机设计* CSDN			:	辰哥单片机设计* 作者			:	辰哥 **********************BEGIN***********************/void USART1_Config(void);
int fputc(int ch, FILE *f);
void USART1_printf(USART_TypeDef* USARTx, uint8_t *Data,...);
void UART1SendByte(unsigned char SendData);
void music_play(unsigned char dat);#endif /* __USART1_H */

usart.c文件

#include "usart.h"
#include <stdarg.h>/*****************辰哥单片机设计******************STM32* 项目			:	JQ6500语音模块实验                     * 版本			: V1.0* 日期			: 2025.2.7* MCU			:	STM32F103C8T6* 接口			:	参串口1						* BILIBILI	:	辰哥单片机设计* CSDN			:	辰哥单片机设计* 作者			:	辰哥 **********************BEGIN***********************/void USART1_Config(void)
{GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;/* 使能 USART1 时钟*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE); /* USART1 使用IO端口配置 */    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOA, &GPIO_InitStructure);    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;	//浮空输入GPIO_Init(GPIOA, &GPIO_InitStructure);   //初始化GPIOA/* USART1 工作模式配置 */USART_InitStructure.USART_BaudRate = 9600;	//波特率设置:9600USART_InitStructure.USART_WordLength = USART_WordLength_8b;	//数据位数设置:8位USART_InitStructure.USART_StopBits = USART_StopBits_1; 	//停止位设置:1位USART_InitStructure.USART_Parity = USART_Parity_No ;  //是否奇偶校验:无USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;	//硬件流控制模式设置:没有使能USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//接收与发送都使能USART_Init(USART1, &USART_InitStructure);  //初始化USART1USART_Cmd(USART1, ENABLE);// USART1使能
}/* 描述  :重定向c库函数printf到USART1*/ 
int fputc(int ch, FILE *f)
{
/* 将Printf内容发往串口 */USART_SendData(USART1, (unsigned char) ch);while (!(USART1->SR & USART_FLAG_TXE));return (ch);
}/*发送一个字节数据*/
void UART1SendByte(unsigned char SendData)
{	   USART_SendData(USART1,SendData);while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);	    
} void music_play(unsigned char dat)
{unsigned char  music_code[6] = {0X7E,0X04,0X03,0X00,0X01,0XEF};	int i;music_code[4] = dat;for(i=0;i<6;i++){UART1SendByte(music_code[i]);}
}

四、实验效果 

五、资料获取

项目分享

http://www.xdnf.cn/news/192979.html

相关文章:

  • C++ 之 【模拟实现 list(节点、迭代器、常见接口)】(将三个模板放在同一个命名空间就实现 list 啦)
  • 电子电器架构 -- 汽车零部件DV试验与PV试验的定义及关键差异
  • [ 问题解决 ] sqlite3.ProgrammingError: SQLite objects created in a thread can ...
  • mybatis的xml ${item}总是更新失败
  • npm init、换源问题踩坑
  • 【Python数据驱动决策】数据分析与可视化全流程实战指南
  • 论文导读 - 基于边缘计算、集成学习与传感器集群的便携式电子鼻系统
  • Vue基础(7)_计算属性
  • C++核心编程:类与对象全面解析
  • Infrared Finance:Berachain 生态的流动性支柱
  • 车载软件架构 --- AUTOSAR的方法论
  • SwiftUI 8.List介绍和使用
  • 零基础制作Freertos智能小车(教程非常简易)持续更新中....
  • DeepSeek创始人梁文峰是个什么样的人?
  • LLM - Large Language Model
  • Android Studio 中使用 SQLite 数据库开发完整指南(Kotlin版本)
  • Redis最佳实践
  • nginx代理websocket时ws遇到仅支持域名访问的处理
  • 23种设计模式 -- 工厂模式
  • 算力困局:AI 狂飙背后的能源枷锁与破局之道
  • 后端[特殊字符][特殊字符]看前端之Row与Col
  • 1.9多元函数积分学
  • Day15(贪心算法)——LeetCode121.买卖股票的最佳时机55.跳跃游戏
  • 【计网】计算机网络的类别与性能
  • Rust 学习笔记:修复所有权常见错误
  • cookie和session
  • Flink Checkpoint 与实时任务高可用保障机制实战
  • DBeaver详细安装步骤
  • 【AI】【MCP】搭建私人王炸MCP自动化工作流
  • 微信jdk 前端vue获取流程1、