现在都市的生活越来越忙,很多人都没有时间和精力来管理一些细节上的东西,比如,在合适的阳光温度时间内晾晒衣服。针对这来问题开始研究,通过对智能晾衣架控制系统的设计与实现的不断探究,得到了比较好的设计思路。
使用CC2530单片机的ADC接口采集雨滴传感器的模拟值,得到雨滴传感器的雨滴测量值之后,与预先设置的阀值进行对比,是否要打开或者收回晾衣杆,这个晾衣杆的伸缩采用步进电机进行模拟;并且还支持语音控制、手动控制晾衣杆的伸缩。

2. 硬件介绍2.1 CC2530开发板

2.2 雨滴传感器

2.3 步进电机

2.4 MR-LD3320语音识别模块

3. 源代码

<<8|dat[0];
 
  return adc_dat;
}
// P0.6
void Init_ADC6(void)
{
    APCFG  |=1<<6;  //PCFG[7:0]选择P0.7- P0.0作为模拟I/O
    P0SEL  |= 0x01; 
    P0DIR  &= ~0x01;   
    
    P0SEL |= (1<<6);      //P0_6端口设置为外设功能
    P0DIR &= ~(1<<6);     //P0_6端口设置为输入端口
    APCFG |= 1<<6;        //P0_6作为模拟I/O使用
}
//读取光敏传感器的值  P0.6
u16 Get_ADC6_Value( void )
{
  u16 reading = 0;
  
  /* Enable channel */
  ADCCFG |= 0x40;
  
  /* writing to this register starts the extra conversion */
  ADCCON3 = 0x86;// AVDD5 引脚  00: 64 抽取率(7 位ENOB)  0110: AIN6
  
  /* Wait for the conversion to be done */
  while (!(ADCCON1 & 0x80));
  
  /* Disable channel after done conversion */
  ADCCFG &= (0x40 ^ 0xFF); //按位异或。如1010^1111=0101(二进制)
  
  /* Read the result */
  reading = ADCL;
  reading |= (u16) (ADCH << 8); 
  
  reading >>= 8;
 
 return (reading);
}

typedef unsigned char uchar;
typedef unsigned int uint;
#define A1 P0_4 //定义步进电机连接端口
#define B1 P0_5
#define C1 P0_6
#define D1 P0_7
uchar phasecw[4] ={0x80,0x40,0x20,0x10};//正转 电机导通相序 D-C-B-A
uchar phaseccw[4]={0x10,0x20,0x40,0x80};//反转 电机导通相序 A-B-C-D
void MotorData(uchar data)
{
 A1 = 1&(data>>4);
 B1 = 1&(data>>5);
 C1 = 1&(data>>6);
 D1 = 1&(data>>7);
}
//ms延时函数
void Delay_MS(uint x)
{
 uint i,j;
 for(i=0;i

uint lenU1 = 0;
uchar tempRXU1;
#define MAXCHAR 81
uchar RecdataU1[MAXCHAR];
unsigned char dataRecv;
unsigned char Flag = 0;
void clearBuffU1(void)
{
 int j;
 for(j=0;j
			
			
			
						
			
 我要赚赏金
