当前位置:网站首页>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
边栏推荐
- “昆明城市咖啡地圖”活動再度開啟
- I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
- 孙安民作品《莲花净心》数字藏品上线长城数艺
- R语言aov函数进行重复测量方差分析(Repeated measures ANOVA、其中一个组内因素和一个组间因素)、分别使用interaction.plot函数和boxplot对交互作用进行可视化
- keras ‘InputLayer‘ object is not iterable
- Curl --- the request fails when the post request parameter is too long (more than 1024b)
- CVPR 2022 | 清华&字节&京东提出BrT:用于视觉和点云3D目标检测的桥接Transformer
- [AGC] build service 3- authentication service example
- Chen Haotian won the national championship of the national finals of the 7th children's model star ceremony
- 机器人系统动力学——惯性参数
猜你喜欢

MySQL log management, backup and recovery of databases (1)

Oracle creates a stored procedure successfully, but the compilation fails

MySQL log management, backup and recovery of databases (2)
[email protected]在oled上控制一条狗的奔跑"/>技能梳理[email protected]在oled上控制一条狗的奔跑

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

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

‘Failed to fetch current robot state‘ when using the ‘plan_kinematic_path‘ service #868

How to seize the opportunity of NFT's "chaos"?

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

Dyson design award, changing the world with sustainable design
随机推荐
Nlopt -- Nonlinear Optimization -- principle introduction and application method
MySQL index, transaction and storage engine of database (3)
OSError: [Errno 28] No space left on device
Jinbei LT6 is powerful in the year of the tiger, making waves
The human agent of kDa, Jinbei kd6, takes you to explore the metauniverse
GD32 RT-Thread PWM驱动函数
SolidWorks质量特性详解(惯性张量、转动惯量、惯性主轴)
GD32 RT-Thread RTC驱动函数
技能梳理[email protected]體感機械臂
Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...
从0使用keil5软件仿真调试GD32F305
戴森设计大奖,以可持续化设计改变世界
The AOV function of R language was used for repeated measures ANOVA (one intra group factor and one inter group factor) and interaction Plot function and boxplot to visualize the interaction
[C language quick start] let you know C language and get started with zero basics ③
2022第六季完美童模 托克逊赛区 决赛圆满落幕
Es common curl finishing
Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development
Curl --- the request fails when the post request parameter is too long (more than 1024b)
100个句子记完7000个雅思词汇,实际只有1043个词汇(包括 I and you 等简单词汇)
MySQL index, transaction and storage engine of database (1)