标题:
基于stm32单片机的智能垃圾桶程序与Proteus仿真图
[打印本页]
作者:
taisenfag
时间:
2023-1-5 18:50
标题:
基于stm32单片机的智能垃圾桶程序与Proteus仿真图
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
51hei.gif
(103.11 KB, 下载次数: 38)
下载附件
2023-1-10 14:46 上传
单片机源程序如下:
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "lcd.h"
#include "usart.h"
#include "adc.h"
#include "motor.h"
int main(void)
{
int key=0;
u16 adcx=0;
int i;
int str=0;
//float temp;
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
Adc_Init(); //ADC初始化
motor_init();
KEY_Init(); //IO初始化
while(1)
{
// key=Remote_Scan();
// // printf("发送消息\n");
// //printf("%d\n",adcx);
// adcx=Get_Adc_Average(ADC_Channel_1,10);
// switch(key)
// {
//
// case 104:str=1;break;
// case 152:str=2;break;
// case 176:str=3;break;
// case 48:str=4;break;
// case 24:str=5;break;
// case 122:str=6;break;
// case 16:str=7;break;
// case 56:str=8;break;
// case 90:str=9;break;
// case 66:str=0;break;
// }
// adcx=4096-adcx;
// printf("\n %d/n",adcx);
//// i=adcx/1000;
//if(PAin(3)==0)//黑色指示灯亮,代表0
if(PAin(3)==0)
{
delay_ms(20);
if(PAin(3)==0)
{
if(PAin(5)==0)
{
printf("垃圾桶1打开 \r\n");
motor_back1(3,4);
}
else
{
printf("垃圾桶2打开 \r\n");
motor_back2(3,4);
}
while(1)
{
if(PAin(3)==1)
{
delay_ms(20);
if(PAin(3)==1)
{
break;
}
}
}
if(PAin(5)==0)
motor_front1(3,4);
else
motor_front2(3,4);
}
}
}
}
复制代码
本人初学,仅供参考,存在错误和不足之处,请大家回帖多多指教,切勿照搬,文件下载:
Keil代码与Proteus8.13仿真下载:
基于stm32智能垃圾桶.7z
(284.31 KB, 下载次数: 60)
2023-1-10 14:50 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1