当前位置:网站首页>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
边栏推荐
- “昆明城市咖啡地图”活动再度开启
- 技能梳理[email protected]+adxl345+电机震动+串口输出
- 孙安民作品《莲花净心》数字藏品上线长城数艺
- I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
- 机器学习面试准备(一)KNN
- Jump table introduction
- Leetcode question brushing (III) -- binary search (go Implementation)
- 著名画家史国良《丰收时节》数字藏品上线长城数艺
- RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装
- 6.Redis新数据类型
猜你喜欢

KOREANO ESSENTIAL打造气质职场范

Implementation of monitor program with assembly language

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

Jump table introduction

CSDN博客运营团队2022年H1总结

“昆明城市咖啡地图”活动再度开启

机器学习面试准备(一)KNN

2022第六季完美童模 托克逊赛区 决赛圆满落幕

The famous painter shiguoliang's "harvest season" digital collection was launched on the Great Wall Digital Art
[email protected]+adxl345+电机震动+串口输出"/>技能梳理[email protected]+adxl345+电机震动+串口输出
随机推荐
Koreano essential creates a professional style
背课文记单词,读课文记单词,读文章记单词;40篇文章搞定3500词;71篇文章突破中考单词;15篇文章贯通四级词汇;15篇文章贯通六级词汇
孙安民作品《莲花净心》数字藏品上线长城数艺
采坑:Didn‘t receive robot state (joint angles) with recent timestamp within 1 seconds.
Compare the maximum computing power of the Cenozoic top ant s19xp and the existing s19pro in bitland
Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect
train_de.py: error: argument --save_steps: invalid int value: ‘$[$[889580/128/4]*10/2]‘
机器学习面试准备(一)KNN
Curl --- the request fails when the post request parameter is too long (more than 1024b)
GD32 RT-Thread PWM驱动函数
6.Redis新数据类型
技能梳理[email protected]在oled上控制一条狗的奔跑
MIT-6874-Deep Learning in the Life Sciences Week4
【Rust日报】2021-01-23 几个新库发布
Get through the supply chain Shenzhen gift show helps cross-border e-commerce find ways to break the situation
【Rust日报】2021-01-22 首份Rust月刊杂志邀请大家一起参与
“昆明城市咖啡地图”再度开启,咖啡拉近城市距离
GNN hands on practice (II): reproduction graph attention network gat
Getting started with X86 - take over bare metal control
Guolin was crowned the third place of global popularity of perfect master in the third quarter of 2022