標(biāo)題:
基于stm32單片機(jī)的智能垃圾桶程序與Proteus仿真圖
[打印本頁(yè)]
作者:
taisenfag
時(shí)間:
2023-1-5 18:50
標(biāo)題:
基于stm32單片機(jī)的智能垃圾桶程序與Proteus仿真圖
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.gif
(103.11 KB, 下載次數(shù): 38)
下載附件
2023-1-10 14:46 上傳
單片機(jī)源程序如下:
#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(); //延時(shí)函數(shù)初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級(jí)分組為組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
uart_init(115200); //串口初始化為115200
Adc_Init(); //ADC初始化
motor_init();
KEY_Init(); //IO初始化
while(1)
{
// key=Remote_Scan();
// // printf("發(fā)送消息\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打開(kāi) \r\n");
motor_back1(3,4);
}
else
{
printf("垃圾桶2打開(kāi) \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);
}
}
}
}
復(fù)制代碼
本人初學(xué),僅供參考,存在錯(cuò)誤和不足之處,請(qǐng)大家回帖多多指教,切勿照搬,文件下載:
Keil代碼與Proteus8.13仿真下載:
基于stm32智能垃圾桶.7z
(284.31 KB, 下載次數(shù): 60)
2023-1-10 14:50 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1