仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include <reg52.h>
- #include <intrins.h>
- #include <string.h>
- #define uint unsigned int
- #define uchar unsigned char
- sbit LED = P3^7;
- sbit in_put = P1^4;
- sbit SW1=P0^0;
- sbit SW2=P0^1;
- sbit moto1=P2^0;
- sbit moto2=P2^1;
- sbit hongwai = P3^0;
- void main(void)
- {
- while(1)
- {
- if(in_put == 1 && SW1 != 0)
- {
- moto1=0;
- moto2=1;
- }
- else if(in_put == 0 && SW2 != 0)
- {
- moto1=1;
- moto2=0;
- }
- else
- {
- moto1=1;
- moto2=1;
- }
- if(hongwai==0)
- {
- LED=1;
- }
- else
- {
- LED=0;
- }
- }
- }
复制代码
目前在学习摸索中,仿真程序还很不完善,求大神指导:
基于51单片机的红外智能垃圾桶源程序和原理图.zip
(48.45 KB, 下载次数: 133)
|