当前位置:网站首页>Skill combing [email protected] voice module +stm32+nfc
Skill combing [email protected] voice module +stm32+nfc
2022-06-30 10:31:00 【Sky_ Lannister】
Car nfc The module detects that different cards broadcast different sounds , Similar to the previous design , It is to achieve an effect similar to the one in which the bus swipes its card to broadcast the battle
1、 Project brief introduction

2、 Implementation logic
# See introduction
3、 Application scenarios
# Broadcast at the bus stop
4、 Sort out the core code
// Global variable definition
unsigned int speed_count=0;// Duty cycle counter 50 Next cycle
char front_left_speed_duty=SPEED_DUTY;
char front_right_speed_duty=SPEED_DUTY;
char behind_left_speed_duty=SPEED_DUTY;
char behind_right_speed_duty=SPEED_DUTY;
unsigned char tick_5ms = 0;//5ms Counter , The fundamental period of the principal function
unsigned char tick_1ms = 0;//1ms Counter , As the basic counter of the motor
unsigned char tick_200ms = 0;// Refresh the display
char ctrl_comm = COMM_STOP;// Control command
char ctrl_comm_last = COMM_STOP;// Last instruction
unsigned char continue_time=0;
unsigned char bt_rec_flag=0;// Bluetooth control flag bit
char id_sound = 0;
int main(void)
{
delay_init();
GPIOCLKInit();
UserLEDInit();
LCD1602Init();
//IRCtrolInit();
TIM2_Init();
MotorInit();
ServoInit();
MeasureInit();
RedRayInit();
//USART3Conf(9600);
USART2Conf(9600);
while(1)
{
if(tick_5ms >= 5)
{
tick_5ms = 0;
tick_200ms++;
if(tick_200ms >= 40)
{
tick_200ms = 0;
LEDToggle(LED_PIN);
LCD1602WriteSpeed(front_left_speed,front_right_speed);
}
// continue_time--;//200ms Stop without receiving instructions
// if(continue_time == 0)
// {
// continue_time = 1;
// CarStop();
// }
//do something
MeasureSpeed();
LCD1602WriteCommand(ctrl_comm);
VoidRun();
}
/// Voice control related
if(id_sound != 0)
{
CarStop();
if(id_sound == 1)
{
IO1_RESET;
Delayms(2000);
}
else if(id_sound == 2)
{
IO2_RESET;
Delayms(2000);
}
else if(id_sound == 3)
{
IO3_RESET;
Delayms(2000);
}
Delayms(5000);
IO1_SET;
IO2_SET;
IO3_SET;
id_sound = 0;
}
}
}
void CarMove(void)
{
BEHIND_RIGHT_EN;
// Left front wheel
/* if(front_left_speed_duty > 0)// forward { if(speed_count < front_left_speed_duty) { FRONT_LEFT_GO; } else { FRONT_LEFT_STOP; } } else if(front_left_speed_duty < 0)// backward { if(speed_count < (-1)*front_left_speed_duty) { FRONT_LEFT_BACK; } else { FRONT_LEFT_STOP; } } else // stop it { FRONT_LEFT_STOP; } */
// Right front wheel
if(front_right_speed_duty > 0)// forward
{
if(speed_count < front_right_speed_duty)
{
FRONT_RIGHT_GO;
}else // stop it
{
FRONT_RIGHT_STOP;
}
}
else if(front_right_speed_duty < 0)// backward
{
if(speed_count < (-1)*front_right_speed_duty)
{
FRONT_RIGHT_BACK;
}
else // stop it
{
FRONT_RIGHT_STOP;
}
}
else // stop it
{
FRONT_RIGHT_STOP;
}
// Left rear wheel
if(behind_left_speed_duty > 0)// forward
{
if(speed_count < behind_left_speed_duty)
{
BEHIND_LEFT_GO;
}
else // stop it
{
BEHIND_LEFT_STOP;
}
}
else if(behind_left_speed_duty < 0)// backward
{
if(speed_count < (-1)*behind_left_speed_duty)
{
BEHIND_LEFT_BACK;
}
else // stop it
{
BEHIND_LEFT_STOP;
}
}
else // stop it
{
BEHIND_LEFT_STOP;
}
// Right rear wheel
/* if(behind_right_speed_duty > 0)// forward { if(speed_count < behind_right_speed_duty) { BEHIND_RIGHT_GO; } else // stop it { BEHIND_RIGHT_STOP; } } else if(behind_right_speed_duty < 0)// backward { if(speed_count < (-1)*behind_right_speed_duty) { BEHIND_RIGHT_BACK; } else // stop it { BEHIND_RIGHT_STOP; } } else // stop it { BEHIND_RIGHT_STOP; } */
}
// forward
void CarGo(void)
{
//front_left_speed_duty=SPEED_DUTY+30;
behind_left_speed_duty=SPEED_DUTY-10;
front_right_speed_duty=SPEED_DUTY-10;
//behind_right_speed_duty=SPEED_DUTY;
}
// back off
void CarBack(void)
{
//front_left_speed_duty=-SPEED_DUTY;
front_right_speed_duty=-SPEED_DUTY;
behind_left_speed_duty=-SPEED_DUTY;
//behind_right_speed_duty=-SPEED_DUTY;
}
// towards the left
void CarLeft(void)
{
//front_left_speed_duty=-10;
front_right_speed_duty=SPEED_DUTY+10;
behind_left_speed_duty=-30;
// behind_right_speed_duty=SPEED_DUTY+60;// Increase rear wheel drive
}
// towards the right
void CarRight(void)
{
// front_left_speed_duty=SPEED_DUTY;
front_right_speed_duty=-20;
behind_left_speed_duty=SPEED_DUTY+5;// Increase rear wheel drive
// behind_right_speed_duty=SPEED_DUTY;
}
// stop it
void CarStop(void)
{
//front_left_speed_duty=0;
front_right_speed_duty=0;
behind_left_speed_duty=0;
// behind_right_speed_duty=0;
}
void MotorInit(void)
{
MotorGPIO_Configuration();
CarStop();
}
Trace , The trolley movement is controlled by judging the states of the three photoelectric pairs
void SearchRun(void)
{
// All three channels have detected
if(SEARCH_L_IO == BLACK_AREA && SEARCH_M_IO == BLACK_AREA && SEARCH_R_IO == BLACK_AREA ) // Three way black line stops
{
CarStop();//ctrl_comm = COMM_UP; // Forward
//return;
}
else if(SEARCH_L_IO == WHITE_AREA && SEARCH_M_IO ==BLACK_AREA && SEARCH_R_IO ==BLACK_AREA)// Right
{
CarRight();//ctrl_comm = COMM_RIGHT;
}
else if(SEARCH_L_GPIO ==WHITE_AREA && SEARCH_M_IO ==WHITE_AREA && SEARCH_R_IO ==BLACK_AREA)
{
CarRight();
}
else if(SEARCH_L_IO == BLACK_AREA && SEARCH_M_IO ==BLACK_AREA && SEARCH_R_IO ==WHITE_AREA)// Left
{
CarLeft();//ctrl_comm = COMM_LEFT;
}
else if(SEARCH_L_IO ==BLACK_AREA && SEARCH_M_IO ==WHITE_AREA && SEARCH_R_IO ==WHITE_AREA)
{
CarLeft();
}
else if( SEARCH_L_IO == WHITE_AREA && SEARCH_M_IO == BLACK_AREA && SEARCH_R_IO ==WHITE_AREA)// in
{
CarGo();//ctrl_comm = COMM_UP;
}
else if(SEARCH_L_IO ==BLACK_AREA && SEARCH_M_IO==WHITE_AREA && SEARCH_R_IO==BLACK_AREA)
{
CarGo();
}
else if(SEARCH_L_IO ==WHITE_AREA && SEARCH_M_IO ==WHITE_AREA && SEARCH_R_IO ==WHITE_AREA)
{
CarGo();
}
}
5、 Some references
# With JQ8900-16P Voice module
#nfc Modules are also readily available , It is detected that the card passes through the serial port to mcu Send card number
6、 matters needing attention
# The card number has been written in the car program in advance
Full operational project address
边栏推荐
- 新冠无情人有情,芸众惠爱心善举暖人间——捐赠商丘市儿童福利院公益行动
- AttributeError: ‘Version‘ object has no attribute ‘major‘
- 技能梳理[email protected]+adxl345+电机震动+串口输出
- 今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
- NLopt--非线性优化--原理介绍及使用方法
- SolidWorks质量特性详解(惯性张量、转动惯量、惯性主轴)
- Action bright: take good care of children's eyes together -- a summary of the field investigation on the implementation of action bright in Guangxi
- Implementation of iterative method for linear equations
- 背课文记单词,读课文记单词,读文章记单词;40篇文章搞定3500词;71篇文章突破中考单词;15篇文章贯通四级词汇;15篇文章贯通六级词汇
- "Kunming City coffee map" activity was launched again
猜你喜欢

RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装

Dyson design award, changing the world with sustainable design

Eth is not connected to the ore pool

How to deploy deflationary combustion destruction contract code in BSC chain_ Deploy dividend and marketing wallet contract code

Oracle creates a stored procedure successfully, but the compilation fails

Koreano essential creates a professional style

逸仙电商发布一季报:坚持研发及品牌投入,实现可持续高质量发展

GeoffreyHinton:我的五十年深度学习生涯与研究心法

ArcGIS Pro脚本工具(6)——修复CAD图层数据源

《锦绣中华》中老年公益文旅游-走进佛山敬老院
随机推荐
OSError: [Errno 28] No space left on device
"Hackers and painters" -- why not be stupid
Js获取指定字符串指定字符位置&指定字符位置区间的子串【简单详细】
Configure Yii: display MySQL extension module verification failed
Ant s19xp appeared in 140t, why is it called the computing power ceiling by the world
机器人系统动力学——惯性参数
戴森设计大奖,以可持续化设计改变世界
最新SCI影响因子公布:国产期刊最高破46分!网友:算是把IF玩明白了
RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装
Getting started with X86 - take over bare metal control
6.Redis新数据类型
我在鹅厂淘到了一波“炼丹神器”,开发者快打包
1033 To Fill or Not to Fill
The human agent of kDa, Jinbei kd6, takes you to explore the metauniverse
Leetcode question brushing (I) -- double pointer (go Implementation)
苹果5G芯片被曝研发失败,QQ密码bug引热议,蔚来回应做空传闻,今日更多大新闻在此...
马斯克推特粉丝过亿了,但他在线失联已一周
GD32 RT-Thread PWM驱动函数
Launch of Rural Revitalization public welfare fund and release of public welfare bank for intangible cultural heritage protection of ancient tea tree
转卡通学习笔记