#include <ioCC2530.h>
#include "delay.h"
#include "led.h"
#include "uart.h"
#include "sys.h"
#include "key.h"
#include <string.h>
#include <stdlib.h>
#if 1
typedef unsigned char uchar;
typedef unsigned int uint;
#define LCD_SCL P1_2 //SCLK 时钟 D0(SCLK)
#define LCD_SDA P1_3 //SDA D1(MOSI) 数据
#define LCD_RST P1_7 //_RES hardware reset 复位
#define LCD_DC P0_0 //A0 H/L 命令数据选通端,H:数据,L:命令
#define XLevelL 0x00
#define XLevelH 0x10
#define XLevel ((XLevelH&0x0F)*16+XLevelL)
#define Max_Column 128
#define Max_Row 64
#define Brightness 0xCF
#define X_WIDTH 128
#define Y_WIDTH 64
void DelayMS(unsigned int msec)
{
unsigned int i,j;
for (i=0; i<msec; i++)
for (j=0; j<530; j++);
}
/*********************LCD 延时1ms************************************/
void LCD_DLY_ms(unsigned int ms)
{
unsigned int a;
while(ms)
{
a=1800;
while(a--);
ms--;
}
return;
}
/*********************LCD写数据************************************/
void LCD_WrDat(unsigned char dat)
{
unsigned char i=8, temp=0;
LCD_DC=1;
for(i=0;i<8;i++) //发送一个八位数据
{
LCD_SCL=0;
temp = dat&0x80;
if (temp == 0)
{
LCD_SDA = 0;
}
else
{
LCD_SDA = 1;
}
LCD_SCL=1;
dat<<=1;
}
}
/*********************LCD写命令************************************/
void LCD_WrCmd(unsigned char cmd)
{
unsigned char i=8, temp=0;
LCD_DC=0;
for(i=0;i<8;i++) //发送一个八位数据
{
LCD_SCL=0;
temp = cmd&0x80;
if (temp == 0)
{
LCD_SDA = 0;
}
else
{
LCD_SDA = 1;
}
LCD_SCL=1;
cmd<<=1;;
}
}
/*********************LCD 设置坐标************************************/
void LCD_Set_Pos(unsigned char x, unsigned char y)
{
LCD_WrCmd(0xb0+y);
LCD_WrCmd(((x&0xf0)>>4)|0x10);
LCD_WrCmd((x&0x0f)|0x01);
}
/*********************LCD全屏************************************/
void LCD_Fill(unsigned char bmp_dat)
{
unsigned char y,x;
for(y=0;y<8;y++)
{
LCD_WrCmd(0xb0+y);
LCD_WrCmd(0x01);
LCD_WrCmd(0x10);
for(x=0;x<X_WIDTH;x++)
LCD_WrDat(bmp_dat);
}
}
/*********************LCD复位************************************/
void LCD_CLS(void)
{
unsigned char y,x;
for(y=0;y<8;y++)
{
LCD_WrCmd(0xb0+y);
LCD_WrCmd(0x01);
LCD_WrCmd(0x10);
for(x=0;x<X_WIDTH;x++)
LCD_WrDat(0);
}
}
/*********************LCD初始化************************************/
void LCD_Init(void)
{
P0SEL &= 0xFE; //让P0.0为普通IO口,
P0DIR |= 0x01; //让P0.0为为输出
P1SEL &= 0x73; //让 P1.2 P1.3 P1.7为普通IO口
P1DIR |= 0x8C; //把 P1.2 P1.3 1.7设置为输出
LCD_SCL=1;
LCD_RST=0;
LCD_DLY_ms(50);
LCD_RST=1; //从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
LCD_WrCmd(0xae);//--turn off oled panel
LCD_WrCmd(0x00);//---set low column address
LCD_WrCmd(0x10);//---set high column address
LCD_WrCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
LCD_WrCmd(0x81);//--set contrast control register
LCD_WrCmd(0xcf); // Set SEG Output Current Brightness
LCD_WrCmd(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常
LCD_WrCmd(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常
LCD_WrCmd(0xa6);//--set normal display
LCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
LCD_WrCmd(0x3f);//--1/64 duty
LCD_WrCmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
LCD_WrCmd(0x00);//-not offset
LCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
LCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
LCD_WrCmd(0xd9);//--set pre-charge period
LCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
LCD_WrCmd(0xda);//--set com pins hardware configuration
LCD_WrCmd(0x12);
LCD_WrCmd(0xdb);//--set vcomh
LCD_WrCmd(0x40);//Set VCOM Deselect Level
LCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
LCD_WrCmd(0x02);//
LCD_WrCmd(0x8d);//--set Charge Pump enable/disable
LCD_WrCmd(0x14);//--set(0x10) disable
LCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7)
LCD_WrCmd(0xaf);//--turn on oled panel
LCD_Fill(0xff); //初始清屏
LCD_Set_Pos(0,0);
}
/****************************************8*16的点阵************************************/
const unsigned char F8X16[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一、设计的题目: 基于CC2530设计的智能风扇 二、设计目的 一是随着空调降温设备的频繁使用,全球气候不断变暖空调降温设备排放出的物质对环境的影响越来越大。二是人们在熟睡之后经常因为温度太低而感冒或者温度升高而不适,风扇相比空调更加适用于老人儿童和体质较弱的人使用。 通过物联网技术的智能风扇设计可以解决因为睡熟导致降温设备依旧运行工作,实现更加节能更加智能的控制。 二、设计要求 通过温度传感器对环境温度进行数据采集和语音控制模块来调节风速实现对风扇的智能控制,使风扇随温度变化来自动调节风力大小。 1: 实现语音控制,可以识别到语音命令并自动做出相应的工作; 2: 实现温度实时监测; 3: 实现通过实时温度来自动控制风扇转数; 4: 实现通电后可以进行风扇的开光和转数调节: 三、功能总结 采用DHT11温湿度传感器,采集环境温度,根据设置的温度阀值与采集的环境温度做对比,控制风扇的开关,风扇就是5V的散热风扇。 实现的功能总结如下: 1.按下开发板上的按键控制风扇的开关(LED灯的开关) 2.通过语音控制风扇的开关(LED灯的开关) 语音由语音模块进行识别。 3.在主函数里每500ms采集一次DHT11温度,然后通过OLED显示屏显示。 四、硬件介绍 语音识别模块采用: MR-LD3320 温湿度模块采用: DHT11 OLED采用0.96寸的SPI接口OLED显示屏,分辨率是128x64。 资料包里包含了项目完整源代码,硬件资料手册、原理图、项目设计完整说明书等。
资源推荐
资源详情
资源评论
收起资源包目录
基于CC2530设计的智能风扇.zip (152个子文件)
YS-V0.7.uvgui.11266 91KB
51_DHT11 9KB
51_DHT21 9KB
usart.__i 130B
YS-V0.7.uvgui.Administrator 90KB
YS-V0.7.uvgui.Administrator 89KB
51_DHT21_uvopt.bak 56KB
YS-V0.7_uvopt.bak 55KB
YS-V0.7_uvproj.bak 15KB
YS-V0.7_uvproj.bak 15KB
YS-V0.7_uvopt.bak 7KB
51_DHT21.c.bak 6KB
51_DHT21.Uv2.bak 2KB
51_DHT21_Uv2.Bak 2KB
51_DHT21_Opt.Bak 2KB
51_DHT21.opt.bak 2KB
CC2530F256.cspy.bat 1KB
CC2530F256.cspy.bat 1KB
main.c 22KB
main.c 18KB
LDChip.c 9KB
main.c 9KB
LDChip.c 8KB
main.c 8KB
51_DHT21.c 6KB
usart.c 2KB
usart.c 2KB
uart.c 1KB
uart.c 1KB
delay.c 833B
delay.c 833B
key.c 721B
key.c 721B
Reg_RW.c 679B
Reg_RW.c 601B
sys.c 235B
sys.c 235B
led.c 202B
led.c 202B
CC2530F256.d51 9KB
CC2530F256.d51 9KB
CC2530F256.dbgdt 5KB
CC2530F256.dbgdt 5KB
CC2530F256.dep 8KB
CC2530F256.dep 8KB
CC2530F256.dni 895B
CC2530F256.dni 895B
DHT11.doc 369KB
基于CC2530设计的智能风扇.docx 4.79MB
CC2530F256.ewd 34KB
CC2530F256.ewd 34KB
CC2530F256.ewp 55KB
CC2530F256.ewp 55KB
cc2550.eww 164B
cc2550.eww 164B
STC11XX.H 17KB
STC11XX.H 17KB
LDChip.h 3KB
LDChip.h 3KB
config.h 724B
config.h 724B
Reg_RW.h 304B
Reg_RW.h 304B
delay.h 302B
delay.h 302B
key.h 232B
key.h 232B
uart.h 206B
uart.h 206B
usart.h 192B
usart.h 192B
led.h 139B
led.h 139B
sys.h 76B
sys.h 76B
CC2530F256.hex 32KB
CC2530F256.hex 31KB
V07A.hex 10KB
V07A.hex 10KB
51_DHT11.hex 2KB
V07A.build_log.htm 1KB
V07A.build_log.htm 1012B
V07A.lnp 139B
V07A.lnp 139B
51_DHT11.lnp 48B
51_DHT21.lnp 48B
main.lst 21KB
main.lst 19KB
LDChip.lst 17KB
LDChip.lst 15KB
51_DHT21.LST 12KB
usart.lst 4KB
usart.lst 4KB
Reg_RW.lst 2KB
Reg_RW.lst 2KB
V07A.m51 34KB
V07A.m51 33KB
51_DHT21.M51 12KB
51_DHT11.M51 12KB
LDChip.obj 20KB
共 152 条
- 1
- 2
DS小龙哥
- 粉丝: 4w+
- 资源: 520
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页