산업 제조
산업용 사물 인터넷 | 산업자재 | 장비 유지 보수 및 수리 | 산업 프로그래밍 |
home  MfgRobots >> 산업 제조 >  >> Manufacturing Technology >> 제조공정

SMART CUBE:집을 제어하는 ​​새로운 방법

구성품 및 소모품

아두이노 101
× 1
LED(일반)
파란색 1개 - 노란색 1개 - 녹색 1개 - 빨간색 2개
× 5
저항 221옴
× 5
브레드보드(일반)
필수 사항 아님
× 1
시드 베이스 실드 V2
× 1
Seeed Grove LCD RGB 백라이트
× 1
Seeed Grove 사운드 센서
× 1
씨드 그로브 부저
× 1
시드 그로브 온도 센서
× 1
키패드
× 1
점퍼 와이어(일반)
× 1
9V 배터리(일반)
× 1
9V 배터리 클립
× 1
중밀도 섬유(MDF) 20x30cm
3mm MDF 또는 레이저 절단용 기타 재료
× 1

필요한 도구 및 기계

레이저 커터(일반)
납땜 인두(일반)

앱 및 온라인 서비스

Arduino IDE
Nordic Semiconductor nRF Connect SDK
필수 사항 아님

이 프로젝트 정보

스마트 큐브란?

Smart Cube는 Smart Home 기기용 컨트롤러입니다.

오늘날 우리 집에 있는 모든 기기를 보다 스마트한 방식으로 관리하는 것이 시급함이 되었습니다. . 간단한 것이 필요합니다. 및 직관적 쓰다. 스마트 큐브 해결책이 될 수 있습니다. Arduino 101이 포함된 휴대용 기기입니다. 보드 및 일부 센서 스마트 홈의 기기 및 액추에이터와 통신합니다.

이 조종기의 혁신은 Arduino 101 보드의 혁신과 관련이 있습니다. 블루투스(BLE)를 사용합니다. 조명, 온도 및 TV를 제어하고 스마트폰과 동기화할 수도 있습니다. . 그러나 주요 혁신은 Smart Cube와 상호작용하는 방식입니다. 자이로스코프와 가속도계를 사용하여 제스처로 큐브에는 6개의 면이 있으며 각 면은 특정 기능을 제어합니다. . 윗면을 인식하는 자이로스코프 덕분에 사용하려는 기능이 감지됩니다. 예를 들어 위쪽 위치에 "빛 면"이 있는 큐브를 배치하기만 하면 현재 있는 방의 조명을 열 수 있습니다. . 조명을 끄려면 큐브를 흔들기만 하면 됩니다.

얼굴이 위쪽인 경우 2초 이상 움직이지 않으면 관련 기능이 활성화됩니다. 이 지연 필요한 얼굴을 찾기 위해 큐브를 회전하고 상호 작용할 시간을 가질 수 있도록 만들어졌습니다. 실수로 다른 기능을 활성화하지 않고. 큐브를 2초 이상 흔들면 마지막으로 활성화된 기능이 닫힙니다.

이 프로젝트의 목적은 스마트 컨트롤러를 구축하는 데 도움이 됩니다. . 이 기기에는 수신기가 필요합니다. 데이터를 해석하는 (그림의 스마트 중심) 및 기능 관리 당신의 스마트 홈의. 주요 출력 큐브의 BLE 신호는 여러 가지 방법으로 사용할 수 있습니다. 예를 들어 큐브를 스마트폰 앱과 연결할 수 있습니다. (또는 직접 만드십시오), 또는 다른 Arduino로 스테이션을 구축할 수 있습니다. BLE 데이터를 수집하여 가정의 가전제품을 직접 제어하는 다양한 경우로 인해 이 부분은 귀하의 긴급 상황에 달려 있습니다. 이 가이드에서는 스마트 큐브를 만드는 방법과 개인화하는 방법을 배울 것입니다.

기능:

코드 구조는 개인화하기 쉽습니다. (나중에 코드를 분석함) 제어할 기능을 결정할 수 있습니다. 내가 제어하기로 결정한 기능은 다음과 같습니다.

조명 :UP의 이 얼굴 조명을 열다 당신이 있는 방의. 큐브를 흔들면 조명이 꺼지고 노란색 LED 이 면에서 활성화되어 어둠 속에서 큐브를 찾을 수 있습니다. 커뮤니케이션 당신의 램프와 함께 101 보드의 BLE에 의해 만들어집니다.

온도 :이 얼굴 UP (BLE를 통해) 에어컨 활성화 덥거나 난방 추우면. 열 센서를 사용하여 온도를 감지합니다. 파란색 LED를 엽니다. 컨디셔너가 켜져 있는 경우(눈송이) 또는 빨간색 난방이 활성화된 경우(태양) 하나.

타이머 :이 얼굴 UP LCD 디스플레이에서 볼 수 있는 타이머를 시작합니다. 알람 으로 작동하는 부저가 있습니다. 카운트다운이 끝나면. 흔들면 타이머가 멈추고 남은 시간을 볼 수 있습니다. 카운트다운이 끝나면 LCD의 색상이 파란색에서 빨간색으로 바뀌고 부저가 세 번 울립니다.

TV :이 얼굴 UP TV를 엽니다. 큐브가 리모컨이 됩니다. 당신의 TV를 위해. 버튼 패널이 있습니다. 실수로 터치하는 것을 방지하기 위해 이 면이 UP인 경우에만 활성화되는 숫자가 있습니다. 누른 번호는 BLE를 통해 TV에 연결된 중앙 컨트롤러로 전송됩니다. 큐브를 흔들면 TV가 닫힙니다.

사운드 :이 얼굴 UP 밝기가 방의 소음 수준을 기반으로 하는 LED를 활성화합니다. 사운드 센서 덕분에 소음이 감지됩니다. 큐브를 흔들면 이 기능이 닫힙니다. (원하는 경우 박수를 치는 개인 기능을 활성화할 수 있습니다.)

꺼짐 얼굴:큐브를 흔들지 않으면 이 얼굴은 중립 위치와 같습니다. 아무것도 바뀌지 않는 곳. 종료하려는 경우 모든 것이 OFF면이 위로 향하도록 큐브를 놓고 흔듭니다. 이 제스처는 스마트폰에서 빠르게 종료하려는 경우 누르는 홈 버튼과 같습니다. 빨간색 LED가 있습니다. 큐브가 어두울 때 찾을 수 있도록.

개념과의 차이점:

원래 계획은 IR 커뮤니케이션도 사용하는 것이었습니다. TV를 큐브에 직접 연결하려면 Arduino 101은 (현재로서는) IR 신호를 관리하는 라이브러리를 지원하지 않기 때문에 BLE를 통해 이 라이브러리(예:Arduino UNO)를 관리할 수 있는 스테이션으로 정보를 보내기로 결정했습니다. 이 문제 때문에 라디오 기능을 제거했습니다. (TV 페이스와 매우 유사), 사운드 센서 페이스로 대체합니다. 이 얼굴은 무언가를 활성화하기 위해 큰 소리(손뼉치는 것과 같은)를 인식하는 데 사용할 수 있습니다. 가장 큰 변화는 자료 큐브의. 처음에는 3D 프린터로 제작하려고 했지만 하지만 레이저 커터를 사용하기로 결정했습니다. . 이러한 방식으로 대체하기가 더 쉽습니다. 기능을 변경하려는 경우 얼굴. 예를 들어 타이머 얼굴을 제거하고 고양이 그릇을 자동으로 채우는 얼굴로 변경할 수 있습니다. 모듈식 전체 구조를 다시 만들 필요가 없습니다!

만들어 봅시다:

이 지침에 따라 자신만의 스마트 큐브를 만드십시오. 하드웨어부터 시작하겠습니다. , 전자제품 조립 구성 요소를 먼저 만든 다음 MDF로 만든 큐브의 본체를 레이저로 절단합니다. 이 작업이 끝나면 코드 작동 방식을 설명하겠습니다. 맞춤 설정 방법 . Arduino 101에 코드를 업로드한 후 을 다운로드할 수 있습니다. 큐브의 BLE 출력을 보거나 스마트 홈에 직접 연결하세요!

하드웨어 - 전자 제품:

Arduino 101을 시작해 보겠습니다. 이것이 fritzing입니다. 따라야 할 계획:

그로브 베이스 쉴드 마운트 보드에 연결하고 연결부터 시작합니다.

키패드 :10, 8, 7, 6, 5, 4, 2의 핀 순서로 와이어를 연결해야 합니다.

LED 연결 :

우선 LED를 준비해야 합니다.

- led(양극)의 긴 다리를 220ohm 저항에 연결한 다음 빨간색 와이어(핀에 연결하는 케이블)에 연결합니다.

- 짧은 다리(음극)를 흰색 와이어에 연결합니다(이것은 gnd로 연결됨)

- 부품을 납땜하고 전기 테이프로 덮습니다.

- 모든 흰색 케이블을 단일 흰색 케이블(이것은 gnd로 이동)에 연결하고 모두 함께 납땜합니다.

이제 빨간색 와이어를 Arduino에 연결합니다. GREEN은 핀 9에 연결되고 노란색은 핀 11에 연결되고 빨간색은 핀 12에 연결되고 파란색은 핀 13에 연결되고 마지막 빨간색은 핀 A2에 연결됩니다.

숲 센서 :

숲 센서를 실드에 연결합니다(부착 구성표 참조).

D3에 부저, I2C에 LCD RGB, A0에 온도 센서, A1에 사운드 센서.

자, 이제 모든 전기를 연결했습니다. 부속. 이제 케이스가 필요합니다. .

하드웨어 - 상자

스케치를 다운로드할 수 있습니다. 레이저로 절단할 큐브입니다. 스케치의 빨간 선은 얼굴의 상징입니다. 조각하세요. 그들을. 검은색 선은 잘라야 합니다. 큐브의 내부 치수는 9cm입니다. . 3mm 재질을 사용하면 스케치가 괜찮습니다. , 다른 두께를 사용하는 경우 수정해야 합니다(이 웹사이트:http://www.makercase.com/에서 사용 가능).

내가 선택한 재료는 MDF입니다. (중밀도 섬유) 하지만 원하는 것을 사용할 수 있습니다.

다음은 레이저 컷 사진입니다. :

이제 조립해야 합니다. .

접착했습니다. 지도의 두께를 만들기 위해 판지 몇 조각. 이러한 방식으로 표면과 정렬됩니다. .

이제 키패드를 장착합니다. . 구멍에 삽입하고 접착 필름을 제거한 다음 핀을 다시 연결하십시오.

이제 RGB LCD . 이것은 구멍에 완벽하게 맞습니다.

배터리 커넥터를 준비합시다 :

오래된 변압기 플러그를 잘라 배터리 클립에 연결했습니다. 이러한 방식으로 상자 내부의 공간을 절약할 수 있습니다.

이 시점에서 다음이 있어야 합니다.

이제 배터리를 연결하기만 하면 됩니다. , 코드 업로드 큐브 닫기 !

TIP:큐브를 흔들 때 안정적으로 보드와 배터리를 케이스로 고정하세요.

코드

첨부파일에서 코드를 찾을 수 있습니다. . Arduino IDE를 사용하여 보드에 업로드 (Arduino 101 호환성을 위해 소프트웨어 업데이트를 기억하십시오).

댓글을 달았습니다 코드의 거의 모든 라인을 이해하기 쉽게 만들었습니다. 500개 이상의 라인, 그리 복잡하지 않은 구조를 두려워하지 마십시오.

처음에는 라이브러리와 모든 변수 선언이 있습니다. .

이 부분에는 BLE 서비스의 정의도 있습니다. 및 특징 . 자동화 IO를 사용했습니다. 서비스. 디지털을 사용했습니다. 조명 및 온도에 대한 특성(이는 2비트를 사용하므로 4가지 경우를 코드화할 수 있음) 및 아날로그 TV용(키패드의 모든 코드 전송용).

그런 다음 설정 . 이 팻은 한 번만 실행됩니다. 처음에. 여기서는 컴포넌트를 입력 또는 출력으로 초기화하고 101 보드의 BLE 및 자이로를 초기화합니다.

주요 부분은 루프입니다. . 네 부분으로 나뉩니다:

<울>
  • 1 첫 번째 부분은 Arduino 웹사이트 튜토리얼(https://www.arduino.cc/en/Tutorial/Genuino101CurieIMUAAccelerometerOrientation)에서 복사한 것입니다. 이 부분은 지속적으로 실행됩니다. 방향을 반환합니다. 이사회.
  • 2 두 번째 부분은 얼굴을 활성화합니다. 2초 이상 위쪽 위치에 있는 경우에만 . 밀리 를 사용합니다. 시간을 계산하는 기능입니다. 위치가 변경되면 밀리 값을 기억하고 방향이 동일하게 유지되면 간격(2초) 후에 선택된 면이 true가 된 if-zone에 들어갑니다(4번째 부분).
  • 3 세 번째 부분은 큐브가 흔들린 경우에만 활성화됩니다. 일정한 강도로 2초 이상 마지막 활성화 얼굴 기능이 닫혀 있습니다. 그리고 얼굴은 거짓으로 설정됩니다. . 얼굴이 틀리면 4편에 입장할 수 없습니다.
  • 4 네 번째 부분은 true에만 해당됩니다. 얼굴. 여기에 스마트 큐브의 핵심 기능이 있습니다. 이 부분에서는 루프에서 참인 면만 지속적으로 실행됩니다.
  • 수정할 수 있습니다. 얼굴은 코드를 약간 수정하여 기능합니다. 주요 구조 설명된 대로여야 합니다. if 조건 내 부분을 변경할 수 있습니다. 모든 얼굴.

    if (face2 ==true) { // 온도 면 //여기서 변경 시작 digitalWrite (LEDOFF, LOW); // 이 면이 참이면 OFF면 LED는 LOW입니다. if (central.connected() ==true) { // 큐브가 BLE 연결되어 있으면 // 온도 값 읽기 int val =analogRead(pinTemp); // 아날로그 값을 얻습니다. resistance=(float)(1023-val)*10000/val; // 저항 온도 구하기=1/(log(resistance/10000)/B+1/298.15)-273.15; // 온도 계산 //활성화 조건 if (temperature> tooHot) { // 에어컨 활성화 digitalWrite(LEDhot, LOW); // 가열 led를 닫습니다 digitalWrite(LEDcold, HIGH); // 에어컨 led termoChar.setValue(1); // BLE를 통해 설정 조건 1 =콜드 온 - 핫 오프 } if (temperature  tooCold &&temperature  

    큐브가 흔들릴 때 "true" 부분(이전 코드에서와 같이)과 "false" 부분을 코딩해야 합니다.

    // TEMPERATURE 비활성화 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"); 얼굴2 =거짓; // TEMPERATURE 면이 거짓이 됨 } 

    얼굴을 false로 설정하는 것을 잊지 마세요. 흔들면.

    앱:

    큐브 BLE 출력을 보려면 다운로드할 수 있습니다. 이 앱:nRF Connect

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

    열면 검색하세요. 기기 및 연결 "스마트큐브스케치"로 그런 다음 세 개의 "자동화 IO" 탭이 표시되고 이를 클릭하고 연속 데이터 수집기를 누릅니다.

    일부 기능(조명, 온도, TV)은 큐브가 연결되어야만 실행되기 때문에 큐브를 연결하는 것이 중요합니다.

    작동 방식:동영상

    코드를 업로드하고 배터리를 삽입하고 상자를 닫고...

    ...이제 스마트 큐브가 생겼습니다!

    큐브의 모든 기능과 사용법을 영상으로 만들어 봤습니다.

    결론

    이 프로젝트는 첫 번째 단계일 뿐입니다. 스마트 홈으로. 제 목적은 Arduino 101을 사용하는 것이었습니다. 새로운 것을 생성할 수 있는 가능성 . 가속도계가 및 자이로스코프 이동성 측면에서 이사회에 새로운 기회를 제공합니다. BLE를 사용하면 휴대할 수 있을 뿐만 아니라 연결하기도 쉽습니다. .

    내 프로젝트 중 하나를 구체적으로 실현한 것은 이번이 처음입니다. 그 과정에서 힘들고 어려운 점도 있었지만 결국 많이 배우고 결과에 만족합니다. 이 가이드를 읽는 모든 사람들이 내 작업에서 무언가를 배우고 또한 필요에 따라 이 프로젝트를 수정할 수 있기를 바랍니다. . 제 영어 실력이 형편없지만 이미지가 도움이 되었으면 합니다.

    미래 이 프로젝트의 중심선 그것은 스마트 큐브와 액추에이터(조명, 온도, TV...) 사이의 다리와 같습니다. 이 Centraline은 큐브에서 BLE 신호를 수신하고 이 정보를 사용하여 집에서 똑똑한 일을 합니다.

    Arduino 101을 사용할 기회를 갖게 되어 매우 기쁩니다. 및 그로브 키트 (키트는 프로토타이핑을 위해 매우 간단하고 빠릅니다).

    이런 식으로 보드를 사용하는 것이 영감이 되길 바랍니다. 당신의 프로젝트를 위해. 원하는 대로 맞춤설정할 수 있습니다. :어떤 기능을 만들고 어떤 상황에서 사용할지 궁금합니다!

    이것은 혁명이 아닐 수도 있지만 집과 소통하는 새로운 방법입니다. .

    이 튜토리얼이 마음에 드셨으면 합니다.

    이제 당신의 차례입니다. :큐브에 손을 대고 해킹하세요!

    <섹션 클래스="섹션 컨테이너 섹션 축소 가능" id="코드">

    코드

    <울>
  • SMART CUBE - 주석이 있는 완전한 코드
  • SMART CUBE - 주석이 있는 완전한 코드Arduino
    이것은 Arduino 101에 업로드할 코드입니다. 이 코드를 그대로 사용하거나 필요에 따라 사용자 지정할 수 있습니다. 주석을 따라 작동 방식을 이해하십시오.
    // Libraries#include "CurieIMU.h" // 가속도계 및 자이로스코프#include  // Bluetooth Low Energy#include #include "rgb_lcd .h" // LCD#include  // Keypadrgb_lcd lcd; // LCD 초기화// 블루투스 초기화:BLEPeripheral blePeripheral; // BLE 주변 장치(프로그래밍 중인 보드)// BLE ServicesBLEService lightService("1815"); // BLE 자동화 IO(1815) - 정보 표시BLEService termoService("1815"); // BLE 자동화 IO - 온도 정보BLEService TVService("1815"); // BLE 자동화 IO - tv 정보// BLE 특성BLEUnsignedCharCharacteristic lightsChar("2A56", // BLE 특성 Digital (2A56) - 조명 BLERead | BLENotify);BLEUnsignedCharCharacteristic termoChar("2A56", // BLE 특성 Digital - 온도 BLERead | BLENotify );BLEUnsignedCharCharacteristic TVChar("2A58", // BLE 특성 Analog (2A58) - tv BLERead | BLENotify);// 상수 및 변수 선언:// 얼굴 방향 및 흔들림 기능:int lastOrientation =- 1; // 이전 방향(비교용) unsigned long previousMillis =0; // 마지막 업데이트 unsigned 긴 간격 =2000; // 얼굴 활성화 전 위 위치에서 대기하는 시간 unsigned long SHAKEpreviousMillis =0; // 마지막 업데이트 unsigned long SHAKEinterval =2000; // 얼굴을 흔드는 동안 기다리는 시간 deactivationboolean keep =false; // 이것은 얼굴 방향 변경을 한 번만 계산하는 데 사용됩니다. lastFUNCTION =-1; // 이것은 이전 방향이 무엇인지 알기 위해 사용됩니다.// Faces 초기화:처음에는 모든 면이 false입니다.boolean face0 =false;boolean face1 =false;boolean face2 =false;boolean face3 =false;boolean face4 =false;boolean face5 =false;// LIGHTS faceconst int LEDlights =11; // 핀 11:노란색 led// TEMPERATURE faceconst int pinTemp =A0; // 핀 A0:온도 sensorconst int LEDhot =12; // 핀 12:빨간색 ledconst int LEDcold =13; // 핀 13:파란색 ledfloat 온도; // 온도값 기억int B=3975; // 써미스터플로트 저항의 B 값; // 저항값 memorizationfloat tooHot =26.0; // 에어컨이 작동되는 온도 [SET]float tooCold =23.0; // 히터가 작동되는 온도 [SET]// TIMER faceint BUZZER =3; // 핀 3:부저부울 KEEPtime =false; // 이것은 면 방향 변경을 한 번만 계산하는 데 사용됩니다(계산하는 동안 다시 시작하지 않음)int TIMERmillis =0; // 다음은 카운트다운 결정을 위한 것입니다int 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); lcd.clear(); // 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. 스마트 플랜트 IoT