Make a smart inductive door of which the servo will control to open the door when one of the Line Finders detected that someone is approaching.
Suitable kit: mCookie302
- USB cable*1
- Sensor cable*3
- Sensor shell
- Building blocks or other fixation structures
- Assemble modules and sensors together:
- Stick the red core module, battery base and green hub together;
- Connect the servo connector to pin 6/7 of Hub;
- Connect the servo to pin 1 (the lower three pins) of servo connector;
- Connect the Line Finder to pin A0/A1 and A2/A3 of Hub;
- Plug one end of the USB cable into the battery base and connect the other to the computer.
Required Program Blocks
The distances on the both sides of the door are detected, when the distance of A or B is less than790 (someone is approaching any side), the door will open automatically, and delay 2s for pedestrians to pass by. If the distances of A and B are larger than 800 (there is no one on each side of the door), the door will close.
Start to Program
1. Read and store the distances of the two Line Finders
Variable A is for storing the value of one Line Finder, and variable B is for storing the value of the other. Store the value of A2 Line Finder in variable A, and store the value of A0 Line Finder in variable B.
2. Judge someone is approaching on any side
Distance of A or B is less than 790 (someone is approaching to each side), the servo will rotate to 10 degrees, at the speed of 50 degrees/s (open the door slowly).Delay 2s for pedestrians to pass by.
3. Judge that there is no one on both sides and then close the door
Distances of A and B are larger than 800 (there is no one on both side).
The servo will rotate to 170 degrees at the speed of 50 degrees/s (close the door slowly).
Test the result
When there is no one approaching the door, the servo is at closing door state; when someone is approaching the door, the servo will open the door.
Install the two Line Finders on the two sides of the door, and set up the shape of the door with building blocks. Fix the iron wire on the arm of the servo. When the arm rotates to 170 degrees, the door is closed. When the arm rotates to 10 degrees, the door is open.
Q:If someone is just standing inside the threshold, the sensor is unable to detect him, then thedoor will be closed, can a closing door alarming be added to the door?
A:Of course it can. Just use a buzzer or a LED to alarm
Declaration and assignment. When someone is approaching, the servo controls to open the door
Variable door is for storing the open and closed state of the door.
Assign 1 to door (the door is open)
There is no one on both sides, the door will be closed and the indicator light will light up
If door is 1 (the door is open), the internal program will be executed
Assign 0 to door (the door is closed)
Red LED flashes 3 times (alarming before closing the door)