帮我写全段STM32F103C8T6的吸油烟机控制系统的代码
时间: 2023-08-20 09:18:04 浏览: 85
STM32F103C8实现的SVPWM变频,V/F控制,电压随频率改变,通过模拟量调频,PWM频率4kHz,HAL库编写
5星 · 资源好评率100%
请输入学院编号:";
cin >> collegeId;
for (int i = 0; i < colleges.size(); i++) {
if (colleges[i].id == collegeId) {
cout << "学院名称:" << colleges[i].name << endl好的,以下是一个完整的STM32F103C8T6吸油烟机控制系统的代码,包含;
cout << "男子团体总分:" << colleges[i].maleScore << endl;
cout << "女子团体总分:" << colleges[i].femaleScore << endl;
for (int j = 0; j < projects.size(); j++) {
了一个LCD显示屏和一个温度传感器,仅供参考:
```c
#include "stm32f10x.h cout << projects[j].name << "成绩:";
if (projects[j].gender == 'M') {
for (int k = 0; k < colleges[i].maleScores[j].size(); k++) {
cout << colleges[i].maleScores[j"
#include "delay.h"
#include "lcd1602.h"
#define FAN_PIN GPIO_Pin_0
#define LED_PIN GPIO_Pin_1][k] << " ";
}
} else {
for (int k = 0; k < colleges[i].femaleScores
#define BUTTON_PIN GPIO_Pin_2
#define TEMP_PIN GPIO_Pin_3
float Get_Temp(void);
int main(void)
{
[j].size(); k++) {
cout << colleges[i].femaleScores[j][k] << " ";
}
}
cout << endl;
}
return;
}
}
cout << "未找到该学院!" << endl;
}
void // 初始化GPIO口
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
showTopColleges() {
int projectId;
cout << "请输入项目编号:";
cin >> projectId;
vector< GPIO_InitStructure.GPIO_Pin = FAN_PIN | LED_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_SpeedCollege> topColleges;
for (int i = 0; i < colleges.size(); i++) {
int totalScore = 0;
if (projects[projectId].gender == 'M') {
sort(colleges[i].maleScores[projectId].begin = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = BUTTON_PIN;
GPIO_InitStructure(), colleges[i].maleScores[projectId].end(), greater<int>());
for (int j = 0; j < min((int).GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = TEMP_PIN;
GPIOcolleges[i].maleScores[projectId].size(), 5); j++) {
totalScore += colleges[i].maleScores[projectId][j];
}
} else {
sort(colleges[i].femaleScores[projectId].begin(), colleges[i].femaleScores_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// 初始化LCD显示屏
Init_LCD[projectId].end(), greater<int>());
for (int j = 0; j < min((int)colleges[i].femaleScores[projectId].size(), 5); j++) {
totalScore += colleges[i].femaleScores[projectId][j];
}
1602();
while(1)
{
// 获取当前温度
float temp = Get_Temp();
// 显示温 }
colleges[i].totalScore = totalScore;
topColleges.push_back(colleges[i]);
}
sort(top度到LCD屏幕
char str[16];
sprintf(str, "Temp:%.2fC", temp);
LCD_ShowColleges.begin(), topColleges.end(), cmpCollegeByTotalScore);
cout << "前五名学院:" << endl;
for (int i = 0; i < min((int)topColleges.size(), 5); i++) {
String(0, 0, str);
// 检测按钮是否按下
if(GPIO_ReadInputDataBit(GPIOA, BUTTON cout << topColleges[i].name << "\t" << topColleges[i].totalScore << endl;
}
}
int main() {
while (true) {
cout << "欢迎使用运动会积分系统,请选择操作:" << endl;
_PIN) == 0)
{
// 打开风扇和LED灯
GPIO_SetBits(GPIOA, FAN_PIN | cout << "1. 添加学院" << endl;
cout << "2. 添加项目" << endl;
cout << " LED_PIN);
}
else
{
// 关闭风扇和LED灯
GPIO_ResetBits(GPIOA, FAN3. 输入成绩" << endl;
cout << "4. 统计积分" << endl;
cout << "5. 按学院编号排序输出" << endl;
cout << "6. 按学院名称排序输出" << endl;
cout <<_PIN | LED_PIN);
}
// 如果温度超过30度,打开风扇和LED灯
if(temp > "7. 按学院总分排序输出" << endl;
cout << "8. 按男子团体总分排序输出 30)
{
GPIO_SetBits(GPIOA, FAN_PIN | LED_PIN);
}
else
{
GPIO_Reset" << endl;
cout << "9. 按女子团体总分排序输出" << endl;
cout << "10. 按学院编号查询参加某个项目的情况" << endl;
cout << "11. 按项目编号查询取得Bits(GPIOA, FAN_PIN | LED_PIN);
}
// 稍微延迟一下,让系统可以频繁刷新温前五名的学院" << endl;
cout << "12. 退出" << endl;
int choice;
cin >>度和按钮状态
delay_ms(100);
}
}
float Get_Temp(void)
{
// 读取温度传 choice;
if (choice == 1) {
addCollege();
} else if (choice == 2) {
addProject();
} else if (choice == 3) {
inputScore();
} else if (choice == 4) {
calculate感器的电压值
uint16_t adc_value = ADC_GetConversionValue(ADC1);
float voltage = (float)Score();
} else if (choice == 5) {
sort(colleges.begin(), colleges.end(), cmpCollegeById);
adc_value / 4095.0 * 3.3;
// 计算温度
float temp = (voltage - showColleges();
} else if (choice == 6) {
sort(colleges.begin(), colleges.end(), cmpCollegeByName);
showColleges();
} else if (choice == 7) {
sort(colleges.begin(), colleges.end(), cmp 0.5) * 100;
return temp;
}
```
这个代码使用了一个按钮控制风扇和LEDCollegeByTotalScore);
showColleges();
} else if (choice == 8) {
showMaleScore();
} else if (choice == 9) {
showFemaleScore();
} else if (choice == 10) {
showCollege灯的开关,当温度超过30度时也会自动打开风扇和LED灯。同时,它还ById();
} else if (choice == 11) {
showTopColleges();
} else if (choice == 12使用了一个LCD显示屏和一个温度传感器,可以显示当前的温度。你可以根据你的具体) {
break;
}
}
return 0;
}
```
这个程序实现了以下功能:
1. 添加学院和项目。
2. 输入各个项目的成绩,并计算各学院和各项目的积分。
3.需求进行修改。需要注意的是,这个代码需要使用到delay.h和lcd1602.h这两个头文件, 按学院编号、名称、总分、男子团体总分、女子团体总分等不同形式排序需要自行添加。
阅读全文