Smart Automatic Closing Window

From Microduino Wiki
Revision as of 05:57, 23 March 2017 by Zhangfengfeng (talk) (Created page with "{| style="width: 1000px;" |- | ==Overview== 600px|center Make an automatic window, when the humidity arrives a certain level, the servo wil...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Anywhere line window.jpg

Make an automatic window, when the humidity arrives a certain level, the servo will be controlled to close the window automatically. And it can also be controlled by two Line Finders.
Suitable kits: mCookie302


Module List

Module

Module Number Function
mCookie-Core 1 Core board
Battery box 1 Program download and power supply
mCookie-Hub 1 Sensor adapter plate
Humidity sensor 1 Detect the humidity
Servo 1 Servo
Servo Connector 1 Servo connector
Line Finder 2 Detect objects

Other Equipment

  • USB cable*1
  • Sensor cable*4
  • Sensor shell
  • Lego or other fixation structures
Anywhere line window-module.jpg

Module Setup

Setup

Anywhere line window-step.jpg
  • Assemble modules and sensors together:
    • Stick the red core module, battery base and green extension module together;
    • Connect the servo to pin 6/7 of Hub;
    • Connect the servo to pin 1 of the servo connector (the lower three pins);
    • Connect the Line Finder to pin A0/A1 and A2/A3 of Hub;
    • Connect the Tem&Hum sensor to IIC pin of Hub;
    • Plug one end of the USB cable into the battery base, and connect the other end to the computer;

Programming

Required Program Blocks


Programming Thought

When the humidity is larger than 80% or the Line Finder controlling to close the window has induced the approach of hand, the servo will be controlled to open the door automatically.

Mixly-ctrl-line window.jpg

Start to Program

1. Read the distance values of the two Line Finders and the humidity value and store them.
Variable open is for storing the value of the Line Finder controlling to close the window. Variable close is for storing the value of the Line Finder controlling to open the window. Variable hum is for storing the humidity value of the Tem&Hum sensor. Store the distance value of pin A0 in variable open. Store the distance value of pin A2 in variable close. Store the humidity value in variable hum.

Mixly-ctrl-line window-code.jpg

2. Control to close the window
If the distance of the sensor controlling to close the window is less than 150 or the humidity value id larger than 80, the window will be closed slowly.

Mixly-ctrl-line window-code1.jpg

3. Control to open the window If the distance of the sensor controlling to open the window is less than 150, the window will be opened slowly.

Mixly-ctrl-line window-code2.jpg



Test the result
After upload, approach your hand to the Line Finder of pin A0, the servo will spin to 40 degrees to open the window; approach your hand to the Line Finder of pin A2, the servo will spin to 140 degrees to close the window. Blow to the Tem&Hum sensor, the humidity will increase, when it is higher than 80%, the servo will also close the window.
Start the power supply, control the servo to close the window with the sensor to close the window, then switch the power supply off, at this time, use iron wire to fix the window and servo arm, so that the action of servo and that of the window can be synchronized.

Anywhere line window.jpg



Q: The current window can be closed automatically when it is raining through detecting the humidity value, how to make it can be closed automatically when the temperature is high as well?
A: The Tem&Hum sensor can also detect the temperature, so we just need to judge the current temperature as well.

Add a temperature value to implement the function of closing the window when it is hot.
Variable temp is for storing the temperature value of the Tem&Hum sensor. If the distance value of the sensor controlling to close the window is less than 150, or the humidity value is larger than 80, or the temperature value is larger than 30, the window will be closed.

Mixly-ctrl-line window-code3.jpg

Technical Specification

Relative Cases

FAQ