当前位置:网站首页>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
边栏推荐
- mysql数据库基础:TCL事务控制语言
- Leetcode question brushing (III) -- binary search (go Implementation)
- Leetcode question brushing (IV) -- greedy thought (go Implementation)
- [C language quick start] let you know C language and get started with zero basics ③
- R language plot visualization: use plot to visualize the prediction confidence of the multi classification model, the prediction confidence of each data point of the model in the 2D grid, and the conf
- Basic MySQL operation commands of database
- A brief introduction to database mysql
- Questions about cookies and sessions
- 郭琳加冕 2022第三季完美大师 全球人气季军
- 华南产业集团发力数字经济,城链科技发布会成功召开
猜你喜欢

逸仙電商發布一季報:堅持研發及品牌投入,實現可持續高質量發展

CVPR 2022 | Tsinghua & bytek & JD put forward BRT: Bridging Transformer for vision and point cloud 3D target detection

乡村振兴公益基金启动暨古茶树非遗保护公益行发布

MySQL index, transaction and storage engine of database (1)

Getting started with X86 - take over bare metal control

ArcGIS Pro脚本工具(6)——修复CAD图层数据源
![[AGC] build service 3- authentication service example](/img/32/44547c00476a055557dd1790e18849.png)
[AGC] build service 3- authentication service example

Didn't receive robot state (joint angles) with recent timestamp within 1 seconds

我在鹅厂淘到了一波“炼丹神器”,开发者快打包

Action bright: take good care of children's eyes together -- a summary of the field investigation on the implementation of action bright in Guangxi
随机推荐
MySQL index, transaction and storage engine of database (3)
R语言aov函数进行重复测量方差分析(Repeated measures ANOVA、其中一个组内因素和一个组间因素)、分别使用interaction.plot函数和boxplot对交互作用进行可视化
Notes on numerical calculation - iterative solution of linear equations
技能梳理[email protected]+adxl345+电机震动+串口输出
Ant s19xp appeared in 140t, why is it called the computing power ceiling by the world
Launch of Rural Revitalization public welfare fund and release of public welfare bank for intangible cultural heritage protection of ancient tea tree
How to seize the opportunity of NFT's "chaos"?
技能梳理[email protected]在oled上控制一条狗的奔跑
逸仙電商發布一季報:堅持研發及品牌投入,實現可持續高質量發展
Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...
六月集训(第30天) —— 拓扑排序
JS get the substring of the specified character position and the specified character position interval of the specified string [simple and detailed]
6.Redis新数据类型
Detailed explanation of SolidWorks mass characteristics (inertia tensor, moment of inertia, inertia spindle)
keras ‘InputLayer‘ object is not iterable
MySQL advanced SQL statement of database (2)
A brief introduction to database mysql
那个程序员,被打了。
基于强化学习的股票量化交易Automated-Stock-Trading-Ensemble-Strategy
《锦绣中华》中老年公益文旅游-走进佛山敬老院