亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

SMART CUBE:控制家居的新方法

组件和用品

Arduino 101
× 1
LED(通用)
1 蓝色 - 1 黄色 - 1 绿色 - 2 红色
× 5
电阻 221 ohm
× 5
面包板(通用)
非强制
× 1
Seeed Base Shield V2
× 1
Seeed Grove LCD RGB 背光
× 1
Seeed Grove 声音传感器
× 1
Seeed Grove Buzzer
× 1
Seeed Grove 温度传感器
× 1
键盘
× 1
跳线(通用)
× 1
9V 电池(通用)
× 1
9V 电池夹
× 1
中密度纤维 (MDF) 20x30 厘米
3mm MDF 或其他激光切割材料
× 1

必要的工具和机器

激光切割机(通用)
烙铁(通用)

应用和在线服务

Arduino IDE
Nordic Semiconductor nRF Connect SDK
非强制

关于这个项目

什么是智能立方体?

Smart Cube 是您智能家居设备的控制器。

如今,以更智能的方式管理我们家中的所有设备正成为紧急情况 .我们需要一些简单的直观 使用。 智能立方体 可能是一个解决方案:它是一个包含 Arduino 101 的便携式设备 电路板和一些传感器 与智能家居中的电器和执行器进行通信。

这款遥控器的创新与Arduino 101板的创新有关。它使用蓝牙(BLE) 控制灯光、温度和电视,您还可以将其与智能手机同步 .但主要的创新在于您与 Smart Cube 交互的方式 使用陀螺仪和加速度计通过您的手势。立方体有 6 个面,每个面控制一个特定的功能 .陀螺仪可以识别您要使用的功能,识别上表面。 例如,您可以打开您所在房间的灯光,只需将“光面”放置在上部位置的立方体 .如果你想关灯,你只需要摇动立方体。

如果一张脸UP 并且超过 2 秒没有移动它被激活了相关功能。这个延迟 使您可以有时间旋转并与立方体互动以找到您需要的面 不会意外激活其他功能。当你摇晃魔方超过 2 秒时,最后激活的功能关闭。

该项目旨在帮助您构建智能控制器 . 此设备需要一个接收器 (图中的智能中心线)解释数据管理功能 您的智能家居。主要输出 立方体的 BLE 信号可以以多种方式使用:例如,您可以将立方体与智能手机应用程序连接 (或自己制作),或者您可以用另一个 Arduino 构建一个 收集 BLE 数据并直接控制您家中的电器。由于案件的多样性,这部分取决于您的紧急情况。在本指南中,我们将看到如何构建智能立方体,您将学习如何对其进行个性化设置。

功能:

代码结构易于个性化 (我们稍后分析代码)以便您可以决定要控制哪些功能。这些是我决定控制的功能:

灯光 :这张脸UP 位置打开 你所在的房间。如果你摇晃立方体,灯就会关掉,黄色的led 这张脸被激活,所以你可以在黑暗中找到立方体。 沟通 用你的灯是由101板的BLE制作的。

温度 :这张脸UP 激活(通过 BLE)空调 如果天气很热或加热 如果天气冷。它使用热传感器检测温度 并打开一个蓝色 LED 如果空调打开(雪花)或红色 一个,如果加热被激活(太阳)。

定时器 :这张脸UP 启动您可以在 LCD 显示屏上看到的计时器。有一个蜂鸣器作为警报 倒计时结束时。如果你摇晃你停止计时器,你可以看到剩余的时间。倒计时结束时,LCD 颜色由蓝色变为红色,蜂鸣器发出三声。

电视 :这张脸UP 打开电视。立方体成为遥控器 为您的电视。有一个按钮面板 只有当这张脸向上时才会激活数字,以避免意外触摸。您推送的数字通过 BLE 发送到连接到电视的中央控制器。摇晃魔方,关上电视。

声音 :这张脸UP 激活一个 LED,其亮度取决于房间的噪音水平。通过声音传感器检测到噪音。如果您摇动立方体,您将关闭此功能。 (如果你愿意,你可以拍手激活你的个人功能)。

关闭 脸:如果你不摇动立方体,这张脸就像一个中立位置 其中什么都没有改变。如果您想关闭 一切都将立方体与 OFF 面朝上放置并摇动它。这个手势就像你智能手机上的主页按钮,如果你想快速退出,你可以按下它。有一个红灯 这样你就可以在天黑时找到立方体。

与概念的差异:

最初的计划是还使用IR 通信 将电视直接连接到立方体。因为 Arduino 101 不支持(目前)管理 IR 信号的库,我决定通过 BLE 将信息发送到可以管理该库的站(如 Arduino UNO)。由于这个问题,我删除了收音机功能 (与电视面非常相似),将其替换为声音传感器面。这张脸可用于识别响亮的噪音(如拍手)以激活某些东西。最大的变化在于材料 的立方体。最初我想用 3D 打印机来构建它 但后来我决定使用激光切割机 .这种方式更容易替代 如果你想改变一个功能,一张脸。例如,您可以移除计时器面,并使用自动填充猫碗的面进行更改。 模块化 您不需要重新构建整个结构!

让我们构建它:

按照此说明构建您自己的智能立方体。我们将从硬件开始 , 组装电子设备 首先是组件,然后是由 MDF 制成的立方体的激光切割体。在这个操作之后,我将解释代码是如何工作的 以及如何个性化它 .在 Arduino 101 上上传代码后,您可以下载 app 查看立方体的 BLE 输出或将其直接连接到您的智能家居!

硬件 - 电子:

让我们从您的 Arduino 101 开始。这是 fritzing 计划遵循:

安装 Grove 基础防护罩 并从连接开始。

键盘 :您必须将电线连接到引脚:10、8、7、6、5、4、2。

LED 连接

首先我们要准备好LED:

- 将 LED(阳极)的长腿连接到 220 欧姆电阻,然后连接到红线(这是连接到引脚的电缆)

- 将短腿(阴极)连接到白线(这将连接到地)

- 焊接零件并用电工胶带覆盖

- 将所有白色电缆连接到一根白色电缆(这将连接到接地)并将它们焊接在一起

现在将红线连接到您的 Arduino:绿色连接到引脚 9,黄色连接到引脚 11,红色连接到引脚 12,蓝色连接到引脚 13,最后一根红色连接到引脚 A2。

Grove 传感器 :

将 Grove 传感器连接到屏蔽层(参见附件方案)。

蜂鸣器转D3,LCD RGB转I2C,温度传感器转A0,声音传感器转A1。

好的,现在我们已经连接了所有的 部分。现在你需要案例 .

硬件-盒子

您可以下载草图 用激光切割的立方体。草图中的红线是面的符号,只是雕刻 他们。黑线应该被剪掉。 立方体的内部尺寸是9 cm .如果您使用 3mm 材料,则草图没问题 , 如果你使用不同的厚度你应该修改它(你可以使用这个网站:http://www.makercase.com/)。

我选择的材料是MDF (中密度纤维)但你可以用你想要的。

这是激光切割的一些照片 :

现在我们必须组装它 .

粘合 一些纸板为 LED 增加厚度。通过这种方式,它们将与表面对齐 .

现在我们安装键盘 .将其插入孔中并去除胶膜,然后重新连接引脚。

现在RGB LCD .这非常适合孔。

让我们准备电池连接器 :

我剪掉了一个旧的变压器插头并将其连接到电池夹上。这样我们就节省了盒子内部的空间。

在这一点上,这就是你应该拥有的:

现在您只需要连接电池 , 上传代码关闭立方体

提示:将电路板和电池与外壳固定​​在一起,以便在摇动立方体时它们会稳定。

代码

您可以在附件中找到代码 .使用 Arduino IDE 将其上传到您的开发板中 (记得更新您的软件以兼容 Arduino 101)。

我有评论 几乎每一行代码都让我更容易理解。 500+行别怕,结构没那么复杂。

一开始有库和所有变量声明 .

这部分还有BLEservices的定义 和特点 .我使用了自动化 IO 服务。我使用了数字 灯光和温度的特性(这使用 2 位,因此有 4 种可能的情况需要编纂)和 Analog 用于电视(发送键盘的所有代码)。

然后设置 .这个 pat 只执行一次 一开始。这里我们将组件初始化为输入或输出,并初始化 101 板的 BLE 和陀螺仪。

主要部分是循环 .分为四部分:

  • 1 第一部分复制自Arduino网站教程:(https://www.arduino.cc/en/Tutorial/Genuino101CurieIMUAccelerometerOrientation)这部分不断执行 它返回方向 董事会。
  • 2 第二部分我们激活一张脸 仅当它处于向上位置超过两秒 .我们使用 millis 功能来计算时间。当位置改变时,它会记住毫秒值,如果方向保持不变,在间隔(2 秒)后,我们进入一个 if 区域,在该区域中所选的面变为真(第 4 部分)。
  • 3 只有当立方体摇动时才会激活第三部分 以一定强度持续2秒以上。 上次激活 人脸功能关闭 并且人脸设置为false .如果人脸是假的不能进入第四部分。
  • 4 第四部分只针对true 脸。这里是智能立方体功能的核心。 在这部分中,只会不断执行循环中正确的人脸。

您可以修改 面部功能对代码进行了一些修改。 主要结构 应该和描述的一样。您可以更改 if 条件中的部分 每张脸。

if (face2 ==true) { // TEMPERATURE face //在这里开始改变 digitalWrite (LEDOFF, LOW); // 如果此面为真,则 OFF 面 LED 为 LOW if (central.connected() ==true) { // 如果立方体是 BLE 连接的 // 读取温度值 int val =analogRead(pinTemp); // 得到模拟值电阻=(float)(1023-val)*10000/val; // 得到电阻温度=1/(log(电阻/10000)/B+1/298.15)-273.15; // 计算温度 // 激活条件 if (temperature> tooHot) { // 激活空调 digitalWrite(LEDhot, LOW); // 关闭加热 LED digitalWrite(LEDcold, HIGH); // 打开空调灯 termoChar.setValue(1); // 通过 BLE 设置条件 1 =冷开 - 热关 } if (temperature  tooCold &&temperature  

您必须对“真”部分(如前面的代码)以及立方体摇动时的“假”部分进行编码:

// TEMPERATURE deactivation if (lastFUNCTION ==2) { // TEMPERATURE face //START CHANGING HERE // 如果中央连接到外围设备: if (central.connected() ==true) { digitalWrite (LEDhot,低); // 关闭温度红色 LED digitalWrite(LEDcold, LOW); //关闭温度蓝色led termoChar.setValue(0); // 温度 BLE 信号:0 =冷关闭 - 热关闭 //END HERE } Serial.println("TEMPERATURE false - CLOSE"); face2 =假; // TEMPERATURE 脸变成假的 } 

记得将人脸设为假 当你摇晃它时。

应用:

要查看立方体 BLE 输出,您可以下载 这个应用程序:nRF Connect

https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=it

当您打开它时,只需搜索 用于设备和连接 与“智能立方体素描”。然后你会看到三个“Automation IO”选项卡,点击它们并推送连续数据收集器。

连接立方体很重要,因为只有连接立方体才能执行某些功能(灯光、温度和电视)。

工作原理:视频

上传代码,插入电池,合上盒子,然后……

...现在你有一个 SMART CUBE!

我制作了一个视频,向您展示了立方体的所有功能以及如何使用它。

结论

这个项目只是第一步 到智能家居。我的目的是使用 Arduino 101 创造新事物的潜力 .我认为加速度计陀螺仪 为董事会提供流动性方面的新机会。 使用 BLE, 除了便携之外,还易于连接 .

这是我第一次具体实现我的项目之一(我的意思是使用工作原型)。这很艰难,在路上遇到了一些困难,但最后我学到了很多东西,我对结果很满意。我也希望阅读本指南的每个人都能从我的工作中学到一些东西,并且根据他们的需要修改这个项目 .我很抱歉我的英语不好,但我希望这些图片可以帮助你。

未来 在这个项目中,我希望创建 centraline 这就像智能立方体和执行器(灯光、温度、电视...)之间的桥梁。该中心将接收来自立方体的 BLE 信号,并使用此信息在您的家中进行智能操作。

我很高兴有机会使用 Arduino 101Grove 套件 (该套件非常简单且快速用于原型制作)。

我希望以这种方式使用电路板可以成为灵感 为您的项目。您可以根据需要对其进行个性化我很想知道您将创建哪些函数以及您将在哪些不同的上下文中使用它!

也许这不是一场革命,而是一种与家互动的新方式 .

希望你喜欢这个教程。

现在轮到 :把手放在立方体上并破解它!

代码

  • SMART CUBE - 带有注释的完整代码
SMART CUBE - 带有注释的完整代码Arduino
这是要上传到 Arduino 101 的代码。您可以按原样使用此代码,也可以根据需要进行自定义。按照评论了解它是如何工作的。
// Libraries#include "CurieIMU.h" // 加速度计和陀螺仪#include  // 低功耗蓝牙#include #include "rgb_lcd .h" // LCD#include  // Keypadrgb_lcd lcd; // LCD初始化//蓝牙初始化:BLEPeripheral blePeripheral; // BLE 外围设备(您正在编程的板)// BLE ServicesBLEService lightsService("1815"); // BLE 自动化 IO (1815) - 灯光信息 BLEService termoService("1815"); // BLE 自动化 IO - 温度信息 BLEService TVService("1815"); // BLE 自动化 IO - 电视信息// BLE 特性BLEUnsignedCharCharacteristic lightsChar("2A56", // BLE 特性数字(2A56) - 灯BLERead | BLENotify);BLEUnsignedCharCharacteristic termoChar("2A56", // BLE 特性数字-温度BLERead | BLENotify );BLEUnsignedCharCharacteristic TVChar("2A58", // BLE 特性模拟(2A58) - tv BLERead | BLENotify);// 常量和变量声明:// 人脸方向和抖动函数:int lastOrientation =- 1; // 先前的方向(用于比较)unsigned long previousMillis =0; // 上次更新无符号长间隔 =2000; // 在面激活之前等待向上位置的时间unsigned long SHAKEpreviousMillis =0; // 上次更新unsigned long SHAKEinterval =2000; // 在抖动过程中等待面部去激活的时间boolean keep =false; // 这仅用于计算人脸方向变化的一次int lastFUNCTION =-1; // this is used to know what is the previous rientation// Faces initilization:at the beginning every face is falseboolean face0 =false;boolean face1 =false;boolean face2 =false;boolean face3 =false;boolean face4 =false;boolean face5 =false;// LIGHTS faceconst int LEDlights =11; // pin 11:yellow led// TEMPERATURE faceconst int pinTemp =A0; // pin A0:temperature sensorconst int LEDhot =12; // pin 12:red ledconst int LEDcold =13; // pin 13:blue ledfloat temperature; // temperature value memorizationint B=3975; // B value of the thermistorfloat resistance; // resistance value memorizationfloat tooHot =26.0; // temperature at which the air conditioner is activated [SET]float tooCold =23.0; // temperature at which the heater is activated [SET]// TIMER faceint BUZZER =3; // pin 3:buzzerboolean KEEPtime =false; // this is used to count only one time the face orientation change (not restart while counting)int TIMERmillis =0; // the following are for the countdown determinationint prevSHOWsecond =0;int CountdownInMillis =0;int SHOWmillis =0; // millis value calculation resultint SHOWminute =0; // minutes value to show in the monitor for the countdownint SHOWseconds =0; // seconds value to show in the monitor for the countdownconst int SETminute =2; // set 2 minute timer [SET]const int SETsecond =30; // set 30 seconds timer [SET]// SOUND faceconst int soundLED =9; // pin 9:green led const int soundSENSOR =A1; // pin A0:sound sensorint brightness =0; // green led brightness initialization// TV faceconst byte ROWS =4; // four rows keypadconst byte COLS =3; // three columns keypadchar keys[ROWS][COLS] ={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}}; // keypad button valuesbyte rowPins[ROWS] ={10,8,7,6}; // pin 10,8,7,6:connect to the row pinouts of the keypadbyte colPins[COLS] ={5,4,2}; // pin 5,4,2:connect to the column pinouts of the keypadKeypad keypad =Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // keypad initialization// OFF faceconst int LEDOFF =A2; // pin A2:red ledvoid setup() { pinMode(LEDlights, OUTPUT); // every led is set as an output pinMode(LEDhot, OUTPUT); pinMode(LEDcold, OUTPUT); pinMode(soundLED,OUTPUT); pinMode(LEDOFF, OUTPUT); Serial.begin(9600); // initialize Serial communication CountdownInMillis =(SETminute*60 + SETsecond)*1000; // this calculates the corrispondent value in millis from the minutes and seconds setting lcd.begin(16, 2); // LCD initialization lcd.setRGB(0, 0, 0); // LCD RGB is OFF at the beginning // initialize device Serial.println("Initializing IMU device..."); CurieIMU.begin(); // Set the accelerometer range to 2G CurieIMU.setAccelerometerRange(2); // Enable Shock Detection CurieIMU.setDetectionThreshold(CURIE_IMU_SHOCK, 7000); // 7.0g =7000 mg (this value set the intensity of the shock) CurieIMU.setDetectionDuration(CURIE_IMU_SHOCK, 2000); // 2000ms (this value set the duration of the shock) CurieIMU.interrupts(CURIE_IMU_SHOCK); // BLE setup initialization blePeripheral.setLocalName("SmartCubeSketch"); // the name of the project blePeripheral.setAdvertisedServiceUuid(lightsService.uuid()); // add the lights service UUID blePeripheral.addAttribute(lightsService); // add the BLE lights service blePeripheral.addAttribute(lightsChar); // add the BLE lights characteristic lightsChar.setValue(3); // initial value for this characteristic =3 //BLE lights value meaning:0 =lights off, 1 =lights on, 3 =initial state, 4 =not used blePeripheral.setAdvertisedServiceUuid(termoService.uuid()); // add the temperature service UUID blePeripheral.addAttribute(termoService); // add the BLE temperature service blePeripheral.addAttribute(termoChar); // add the BLE temperature characteristic termoChar.setValue(0); // initial value is 0:cold off - hot off //BLE termo value meaning:0 =cold off - hot off, 1 =cold on - hot off, 2 =cold off - hot on, 3 =not used blePeripheral.setAdvertisedServiceUuid(TVService.uuid()); // add the tv service UUID blePeripheral.addAttribute(TVService); // add the BLE tv service blePeripheral.addAttribute(TVChar); // add the tv characteristic TVChar.setValue('x'); // initial value for this characteristic (x means nothing) //BLE TV value meaning:#number corrispond to the pressed button, C:close TV, O:open TV, x:initial state blePeripheral.begin(); Serial.println("Bluetooth device active, waiting for connections..."); } // setup endvoid loop() { BLECentral central =blePeripheral.central(); // BLE connection unsigned long currentMillis =millis(); // current value of time in milliseconds // the following code comes from www.arduino.cc/en/Tutorial/Genuino101CurieIMUccelerometerOrientation // it is used to detect the orientation of the board int orientation =- 1; // the board's orientation String orientationString; // string for printing description of orientation // read accelerometer:int x =CurieIMU.readAccelerometer(X_AXIS); int y =CurieIMU.readAccelerometer(Y_AXIS); int z =CurieIMU.readAccelerometer(Z_AXIS); // calculate the absolute values, to determine the largest int absX =abs(x); int absY =abs(y); int absZ =abs(z); if ( (absZ> absX) &&(absZ> absY)) { // base orientation on Z if (z> 0) { orientationString ="up"; orientation =0; } else { orientationString ="down"; orientation =1; } } else if ( (absY> absX) &&(absY> absZ)) { // base orientation on Y if (y> 0) { orientationString ="digital pins up"; orientation =2; } else { orientationString ="analog pins up"; orientation =3; } } else { // base orientation on X if (x <0) { orientationString ="connector up"; orientation =4; } else { orientationString ="connector down"; orientation =5; } } // end of the tutorial code. // at this point you have the orientation value of the board constantly updated:/* The orientations of the board:0:flat, processor facing up (TIMER) 1:flat, processor facing down (TV) 2:landscape, analog pins down (TEMPERATURE) 3:landscape, analog pins up (OFF) 4:portrait, USB connector up (LIGHTS) 5:portrait, USB connector down (SOUND) */ // for this project you need to know if the face has changed from the previous face function [lastFUNCTION !=orientation] // but this information is printed only if the face is in the UP position for more than [interval] time // and only for one time [keep] (you don't nedd to constantly activate the face, you just need it one time) // because the orientation value is constantly updated you need to start counting time when the orientation change [orientation !=lastOrientation] if (orientation !=lastOrientation) { // if the orientation has changed, start to count time lastOrientation =orientation; // memorize the current orientation of the face previousMillis =currentMillis; // memorize the time when the face has changed keep =false; } else if (currentMillis - previousMillis> interval &&keep ==false &&lastFUNCTION !=orientation) { //this condition print the orientation only if the face is up for an interval //and only for one time (keep) //and only if the face is different from the previous loop Serial.println(orientationString); // print the orientation // the current face [orientation] is set as true (that means that the face function is set as activated) if (orientation ==1) { // TV face face1 =true; // TV face becomes true lastFUNCTION =orientation; // memorize this activation in [lastFUNCTION] Serial.println("TV true"); // print the activated face TVChar.setValue('O'); // O:open the tv signal (BLE):tv is open only one time } if (orientation ==4) { // LIGHTS face face4 =true; lastFUNCTION =orientation; Serial.println("LIGHTS true"); } if (orientation ==3) { // OFF face face3 =true; lastFUNCTION =orientation; Serial.println("OFF true"); } if (orientation ==5) { // SOUND face face5 =true; lastFUNCTION =orientation; Serial.println("SOUND true"); } if (orientation ==2) { // TEMPERATURE face face2 =true; lastFUNCTION =orientation; Serial.println("TEMPERATURE true"); } if (orientation ==0) { // TIMER face face0 =true; lastFUNCTION =orientation; Serial.println("TIMER true"); if (KEEPtime ==false) { // timer is activated only if it is the 1st cycle or has been stopped TIMERmillis =currentMillis; // start counting time } } keep =true; // [keep] change value so that, in the next loop, you can't enter in this condition if the face don't change (avoid to activate another time the same face) } // this condition is for the shake function:if you shake for more than [SHAKEinterval] time, the face is deactivated if (CurieIMU.getInterruptStatus(CURIE_IMU_SHOCK) &¤tMillis - SHAKEpreviousMillis> SHAKEinterval) { Serial.println("SHAKE"); // print "SHAKE" if shake is detected // the last activated face [lastFUNCTION] is set as false (that means that the face function is deactivated) //TV deactivation if (lastFUNCTION ==1) { // TV face TVChar.setValue('C'); // C:close the tv BLE signal Serial.println("TV false - CLOSE"); // print the closed face face1 =false; // TV face becomes false } //LIGHTS deactivation if (lastFUNCTION ==4) { // LIGHTS face if (central.connected() ==true) { // if a central is connected to peripheral:lightsChar.setValue(0); // lights OFF BLE signal digitalWrite (LEDlights, HIGH); // open the yellow led to see the cube in the dark } Serial.println("LIGHTS false - CLOSE"); face4 =false; // LIGHTS face become false } // OFF if (lastFUNCTION ==3) { // OFF face // OFF face shaked:everything is closed and red led OFF is open digitalWrite (LEDOFF, HIGH); // red led OFF is on when cube is closed // now close all the activated functions:// CLOSE TV TVChar.setValue('C'); // C:close the tv BLE signal Serial.println("TV false - CLOSE"); face1 =false; // CLOSE LIGHTS Serial.println("LIGHTS false - CLOSE"); if (central.connected() ==true) { lightsChar.setValue(0); digitalWrite (LEDlights, LOW); // lights led is closed if OFF face is shaked } face4 =false; // CLOSE SOUND analogWrite(soundLED, LOW); // close the sound led Serial.println("SOUND false - CLOSE"); face5 =false; //CLOSE TEMPERATURE if (central.connected() ==true) { digitalWrite(LEDhot, LOW); digitalWrite(LEDcold, LOW); termoChar.setValue(0); // temperature BLE signal:0 =cold off - hot off } Serial.println("TEMPERATURE false - CLOSE"); face2 =false; // CLOSE TIMER Serial.println("TIMER false - CLOSE"); lcd.setRGB(0, 0, 0); // the LCD RGB is closed lcd.clear(); KEEPtime =false; face0 =false; // The cube is inactive, only OFF led is active Serial.println("OFF false - CLOSE"); face3 =false; // OFF face becomes false } // SOUND deactivation if (lastFUNCTION ==5) { // SOUND face analogWrite(soundLED, LOW); // close the sound led Serial.println("SOUND false - CLOSE"); face5 =false; // SOUND face becomes false } // TEMPERATURE deactivation if (lastFUNCTION ==2) { // TEMPERATURE face // if a central is connected to peripheral:if (central.connected() ==true) { digitalWrite(LEDhot, LOW); // close temperature red led digitalWrite(LEDcold, LOW); // close temperature blue led termoChar.setValue(0); // temperature BLE signal:0 =cold off - hot off } Serial.println("TEMPERATURE false - CLOSE"); face2 =false; // TEMPERATURE face became false } // TIMER deactivation if (lastFUNCTION ==0) { // TIMER face Serial.println("TIMER false - CLOSE"); face0 =false; // TIMER face became false // if you shake the cube when the time is running, the LCD became red and show the remaining time to countdown lcd.setRGB(180, 40, 0); // the RGB backlight become red lcd.clear(); // lcd is cleared lcd.setCursor(0, 0); lcd.print("STOP AT "); lcd.setCursor(8, 0); lcd.print(SHOWminute); // indicates the minutes when you shake the cube lcd.setCursor(9, 0); lcd.print(":"); lcd.setCursor(10, 0); lcd.print(SHOWseconds); // indicates the seconds when you shake the cube tone(BUZZER,1000,1000); // it make a short sound delay(2000);液晶显示器(); // clear the LCD lcd.setRGB(0, 0, 0); // LCD RGB backlight is closed KEEPtime =false; // TIMER face became false } SHAKEpreviousMillis =currentMillis; // memorize the value for the [SHAKEinterval] calculation } // the following instructions are executed in loop only if the face is activated if (face1 ==true) { // TV face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() ==true) { // if the cube is BLE connected char key =keypad.getKey(); // read the value from the keypad if (key &&orientation ==1){ // if something is pressed and only when the tv face is up (avoid involuntary keypad pression) if (key =='0') { // if the pressed key is 0 TVChar.setValue(key); // send the [key] value via BLE Serial.println(key); // print the pressed button (comment if you don't want to show this information) } if (key =='1'){ TVChar.setValue(key); Serial.println(key); } if (key =='2'){ TVChar.setValue(key); Serial.println(key); } if (key =='3'){ TVChar.setValue(key); Serial.println(key); } if (key =='4'){ TVChar.setValue(key); Serial.println(key); } if (key =='5'){ TVChar.setValue(key); Serial.println(key); } if (key =='6'){ TVChar.setValue(key); Serial.println(key); } if (key =='7'){ TVChar.setValue(key); Serial.println(key); } if (key =='8'){ TVChar.setValue(key); Serial.println(key); } if (key =='9'){ TVChar.setValue(key); Serial.println(key); } if (key =='*'){ TVChar.setValue(key); Serial.println(key); } if (key =='#'){ TVChar.setValue(key); Serial.println(key); } } } } if (face4 ==true) { // LIGHTS face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() ==true) { // if a central is connected to peripheral:lightsChar.setValue(1); // LIGHTS activated BLE signal digitalWrite (LEDlights, LOW); // yellow led is closed because the home lights are on } } if (face3 ==true) { // OFF face // when OFF face is up nothing is done digitalWrite (LEDOFF, LOW); // led OFF is activated only when the cube is shaked, so now is LOW } if (face5 ==true) { // SOUND face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW // sound sensor is activated, led brightness regulated by the sond // this code comes from brightness regulation example long sum =0; for (int i=0; i<32; i++) { sum +=analogRead(soundSENSOR); } sum>>=5; brightness =(sum*255)/1024; // calculate the brightness value analogWrite(soundLED,brightness); // green led brightness intensity is regulated by the noise delay(50); //end brightness example } if (face2 ==true) { // TEMPERATURE face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() ==true) { // if the cube is BLE connected // read temperature value int val =analogRead(pinTemp); // get analog value resistance=(float)(1023-val)*10000/val; // get resistance temperature=1/(log(resistance/10000)/B+1/298.15)-273.15; // calculate temperature //conditions of activation if (temperature> tooHot) { // activate air conditioning digitalWrite(LEDhot, LOW); // close heating led digitalWrite(LEDcold, HIGH); // open air conditioner led termoChar.setValue(1); // set via BLE the condition 1 =cold on - hot off } if (temperature  tooCold &&temperature  

定制零件和外壳

This is the file (.dxf) that you can upload on your laser cutter. I used a medium density fiberboard (MDF) of 3mm. Cut the black lines and engrave red lines. Important:if your material thickness is different you have to modify this sketch. smart_cube_8sVCflFmhM.dxfThe same file of the box but in a different format:.pdf

示意图

This is a .jpeg of the Fritzing scheme (yellow wires are connected to Grove components) This is a scheme of the connections in the Grove Shield _cI0IwUsPVZ.Base%20shield%20connections

制造工艺

  1. 为什么太阳能电池板是您家的明智投资
  2. 将新产品设计做大或回家
  3. 家庭自动化应用
  4. 在家中构建无线传感器网络
  5. 使用 Raspberry Pi 监控家中温度
  6. 智能家居技能差距
  7. 变得聪明:你家的未来
  8. 智能安全:如何保护您的智能家居设备免受黑客攻击
  9. 提高智能家居安全性的方法
  10. 智能工厂物联网
  11. 对吊扇启用 Alexa Control
  12. 通过网络或手机控制家用电器