所有分类
主题 主题
平台 平台
我的工作台
userHead
注册时间 [[userInfo.create_time]]
创造力 [[userInfo.creativity]]
[[userInfo.remark]]
[[d.project_title]]
articleThumb
[[d.material_name]]
timelineThumb
进入工作台
折叠
所有分类 我的工作台
展开
智能小屋
VDong VDong 2019-07-23 11:27:17
3
1
简单

        也是心血来潮,刚接触了掌控板的一些简单操作,就想做一个作品出来。

        一开始做的规划很性感。我的作品名字叫《智能小屋》。

       作品的初衷是希望在摄影爱好者经常去的偏僻地方,能有这样一间小屋,可以存放设备,可以避雨,可以拍摄,比如银河呀、山水啦什么的。

       功能包括:1.智能路灯。当有人经过就会亮起。没有人就熄灭。

                  2.密码开锁。从网上获取密码,然后通过触摸数字密码登录。

                  3.室内有风扇,当温度超过29度自动运行。

                  4.有显示屏,可以看到当前的温度、湿度、天气情况。

       以上是我对作品的构想,但现实却及其不如意。 我学掌控用的是盛思的设备,通过mpythonx编程,我购买的设备是掌控板+df的扩展板,用mind+编程。一开始用python,可用的传感器和执行器极少,不得不改用c语言编程。 密码登录,本想着利用扩展板p、y、t、h、o、n的触摸功能,外接杜邦线,加上金属触摸按钮(图钉),实现密码输入。可试过多次,在掌控板上可以实现,接到扩展板就无法实现。于是只能用一个触摸传感器代替了。 单个程序运行的物联网是可以实现连接,但,将物联网程序加到源程序就完全无法运行。目前还没找到原因。

projectImage

好吧,说了这么多,来看看能实现的功能吧。 1.智能路灯。有人经过即亮起。 2触摸按钮开门。接触触摸传感器驱动舵机开门。 3.室温超过29℃自动打开风扇。 4.显示当前温度、湿度,天气。

projectImage

有路人经过灯会自动点亮。这里在屋檐下加了一个人体红外传感器,加了两个led灯,当感应到人体即点亮小灯。检测不到人体,灯灭。

projectImage

手触摸按键可以打开门。在这里加了一个触摸传感器。屋里有一个舵机,控制门的开关。

projectImage

当检测到触摸开关,舵机调整到0度,打开房门。等待10秒,舵机调整到90度,自动关门。

projectImage

在屋内加了lm35温度、湿度传感器。在掌控板上显示当前的湿度和湿度。本想着最后一行显示今日天气,mqtt试验没成功。所以在这里只能显示“今天天气不错”代替了。

projectImage

当屋内温度大于29度,就会驱动风扇电机转动。

projectImage
材料清单 材料清单
1x
掌控板
1x
掌控板i/o扩展板
1x
lm35温度湿度传感器
1x
风扇
1x
人体红外感应传感器
2x
led灯
1x
舵机
代码 代码
	                    					#include <MPython.h>
#include <DFRobot_DHT.h>
#include <DFRobot_Servo.h>

DFRobot_DHT dht11_P1(P1, DHT11);
Servo myservoP8;

const chCode chBuf[] = {
{0x5f53,0xe5bd93,0xB5B1,{0x00,0x00,0x01,0x00,0x21,0x08,0x19,0x30,0x09,0x20,0x01,0x00,0x7f,0xfc,0x00,0x0c,0x00,0x0c,0x3f,0xfc,0x00,0x0c,0x00,0x0c,0x7f,0xfc,0x00,0x0c,0x00,0x00,0x00,0x00}},
{0x524d,0xe5898d,0xC7B0,{0x08,0x20,0x04,0x60,0xff,0xfe,0x00,0x00,0x7f,0x6c,0x41,0x6c,0x7f,0x6c,0x41,0x6c,0x41,0x6c,0x7f,0x6c,0x41,0x0c,0x41,0x0c,0x4e,0x38,0x00,0x00,0x00,0x00,0x00,0x00}},
{0x6e29,0xe6b8a9,0xCEC2,{0x00,0x00,0x47,0xf8,0x24,0x08,0x17,0xf8,0x44,0x08,0x67,0xf8,0x24,0x08,0x00,0x00,0x27,0xfc,0x25,0x24,0x65,0x24,0x65,0x24,0x45,0x24,0x5f,0xfe,0x00,0x00,0x00,0x00}},
{0x5ea6,0xe5baa6,0xB6C8,{0x00,0x00,0x00,0x80,0x3f,0xfe,0x20,0x00,0x24,0x10,0x3f,0xfc,0x24,0x10,0x27,0xf0,0x20,0x00,0x2f,0xf8,0x66,0x10,0x41,0xc0,0x43,0x60,0x98,0x0c,0x00,0x00,0x00,0x00}},
{0xff1a,0xefbc9a,0xff1a,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00}},
{0x6e7f,0xe6b9bf,0xCAAA,{0x00,0x00,0x47,0xfc,0x24,0x0c,0x17,0xfc,0x44,0x0c,0x67,0xfc,0x24,0x0c,0x01,0x20,0x29,0x24,0x25,0x24,0x65,0x2c,0x45,0x28,0x41,0x20,0x4f,0xfe,0x00,0x00,0x00,0x00}},
{0x4eca,0xe4bb8a,0xBDF1,{0x00,0x00,0x01,0x00,0x03,0x80,0x06,0xc0,0x0c,0x60,0x1a,0x30,0x61,0x08,0xc1,0x06,0x00,0x00,0x3f,0xf8,0x00,0x30,0x00,0x60,0x00,0xc0,0x00,0x80,0x00,0x00,0x00,0x00}},
{0x5929,0xe5a4a9,0xCCEC,{0x00,0x00,0x7f,0xfc,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xff,0xfe,0x03,0x00,0x02,0x80,0x06,0x80,0x04,0x40,0x18,0x20,0x30,0x18,0x40,0x04,0x00,0x00,0x00,0x00}},
{0x6c14,0xe6b094,0xC6F8,{0x00,0x00,0x10,0x00,0x10,0x00,0x3f,0xfc,0x20,0x00,0x7f,0xf8,0x40,0x00,0xbf,0xf0,0x00,0x10,0x00,0x10,0x00,0x12,0x00,0x12,0x00,0x0e,0x00,0x0c,0x00,0x00,0x00,0x00}},
{0x4e0d,0xe4b88d,0xB2BB,{0x00,0x00,0x7f,0xfc,0x01,0x80,0x01,0x00,0x03,0x00,0x07,0x00,0x05,0x40,0x09,0x20,0x19,0x18,0x31,0x0c,0x61,0x04,0x81,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00}},
{0x9519,0xe99499,0xB4ED,{0x21,0x10,0x21,0x10,0x7b,0xfc,0x41,0x10,0x79,0x10,0xa7,0xfe,0x20,0x00,0xfb,0xfc,0x22,0x0c,0x23,0xfc,0x2a,0x0c,0x3b,0xfc,0x22,0x0c,0x00,0x00,0x00,0x00,0x00,0x00}},
{0xff01,0xefbc81,0xff01,{0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00}},
};
void setup() {
	mPython.begin();
	display.setChCode(chBuf);
	myservoP8.attach(P8);
}

void loop() {
	display.setCursorXY(80, 0);
	display.print(dht11_P1.getTemperature());
	display.setCursorXY(80, 20);
	display.print(dht11_P1.getHumidity());
	display.setCursorXY(2, 0);
	display.print("当前温度:");
	display.setCursorXY(2, 20);
	display.print("当前湿度:");
	display.setCursorXY(2, 46);
	display.print("今天天气不错!");
	if ((dht11_P1.getTemperature() > 29)) {
		digitalWrite(P9, HIGH);
	}
	else {
		digitalWrite(P9, LOW);
	}
	if (((digitalRead(P14)) == 1)) {
		digitalWrite(P13, HIGH);
	}
	else {
		digitalWrite(P13, LOW);
	}
	if (((digitalRead(P15)) == 1)) {
		digitalWrite(P13, HIGH);
		myservoP8.angle(abs(0));
		delay(10000);
		digitalWrite(P13, LOW);
	}
	else {
		myservoP8.angle(abs(90));
	}
}

	                    				
Makelog作者原创文章,未经授权禁止转载。
3
1
评论
[[c.user_name]] [[c.create_time]]
[[c.parent_comment.count]]
[[c.comment_content]]