当前位置:网站首页>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
边栏推荐
- 机器人系统动力学——惯性参数
- 《锦绣中华》中老年公益文旅游-走进佛山敬老院
- R语言plotly可视化:使用plotly可视化多分类模型的预测置信度、模型在2D网格中每个数据点预测的置信度、置信度定义为在某一点上最高分与其他类别得分之和之间的差值
- Go -- maximum heap and minimum heap
- AttributeError: ‘Version‘ object has no attribute ‘major‘
- Dyson design award, changing the world with sustainable design
- 今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
- What is the real performance of CK5, the king machine of CKB?
- MIT-6874-Deep Learning in the Life Sciences Week5
- "Kunming City coffee map" activity was launched again
猜你喜欢

【C语言快速上手】带你了解C语言,零基础入门③

Koreano essential creates a professional style

MySQL advanced SQL statement of database (2)

KOREANO ESSENTIAL打造气质职场范
[email protected]体感机械臂"/>技能梳理[email protected]体感机械臂

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 (3)

SolidWorks质量特性详解(惯性张量、转动惯量、惯性主轴)

Getting started with X86 - take over bare metal control

Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...
随机推荐
Leetcode question brushing (IV) -- greedy thought (go Implementation)
GD32 RT-Thread OTA/Bootloader驱动函数
I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
Configure Yii: display MySQL extension module verification failed
Js获取指定字符串指定字符位置&指定字符位置区间的子串【简单详细】
Curl --- the request fails when the post request parameter is too long (more than 1024b)
今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
Automated stock trading ensemble strategy based on Reinforcement Learning
Go -- maximum heap and minimum heap
Great Wall digital art digital collection platform releases the creation Badge
KOREANO ESSENTIAL打造气质职场范
MySQL log management, backup and recovery of databases (2)
Chen Haotian won the national championship of the national finals of the 7th children's model star ceremony
The human agent of kDa, Jinbei kd6, takes you to explore the metauniverse
六月集训(第30天) —— 拓扑排序
"Kunming City coffee map" was opened again, and coffee brought the city closer
ArcGIS Pro脚本工具(5)——排序后删除重复项
Implementation of iterative method for linear equations
Highlight display of Jinbei LB box, adhering to mini special effects
Action bright: take good care of children's eyes together -- a summary of the field investigation on the implementation of action bright in Guangxi