Our project mainly focuses on locking and unlocking controlling mechanisms of a gate through motor controls. Through position controlling of a motor we could achieve the locking and unlocking mechanisms. With the help of a photo-resistor we could switch the controller into either day time controlling mode or night time controlling mode. During the day time, the locking and unlocking mechanism is activated from outside the door by an ultrasonic sensor. When the ultrasonic sensor senses the existence of a person in front of the door, the mechanism will control the motor to rotate into unlocking region. While during the night time control mode, the door will be unlocked from outside using a membrane switching module. Once the person outside enters the correct password, the door will be unlocked. For both mode, the motor would return back to locking region 2 seconds after the door is unlocked for safety.
During our project the first problem we faced is writing correct instruction code for the membrane module. As the source code library provided by the vendor is not applicable, we started from understanding the membrane module datasheet and wrote our own code for membrane functionality. Luckily the membrane module turns out working as we expected. Another challenge we face is the number of pins available on our Arduino Uno board is limited. We have to abandon some planned figures including digital display, which counts how many times the door is unlocked, and button control from inside the door. In order to make our project more approximate to real life, we added another figure to our system. We programmed the controlling module to make sure during the day time mode the door is also unlockable using the membrane module. We took the possible ultrasonic sensor failure into consideration. Therefore even when the ultrasonic sensor does not work, a person could still unlock the door by pressing the correct password on the membrane module.
We are trying to control the locking and unlocking mechanisms of a door through position controlling a motor. We are trying to make a gate controlling system applicable in real life. We consider the security level needed during different time of a day as well as the reliability of the system. During night time we may need higher security level. We use a membrane module control, which uses a password as verification, to give entering access to only a certain group of people. We further take the reliability of the system into consideration. While during the day time mode the ultrasonic sensor may have failures. We make the membrane controlling also available during day time mode as a backup unlocking method. Our main purpose of the project is making a practically achievable system that we could use in real life. Therefore we take real life issues or problems into consideration.
Part A Motor Position Control
The motor rotates 180 degrees to simulate “unlocking the door”, and the door will be locked automatically 2 seconds later. Both the locking and unlocking region occupy 180 degrees region. There are two choices for us to achieve the rotation, which are the servo motor and the stepper motor. The servo motor has a faster rotating speed and is controlled by the pulse width of the signal, whereas the stepper motor rotates slower and is driven by different number of pulses. We finally choose the stepper motor since we don’t need a high-speed rotation and controlling the number of pulses is easier. In the same time, the driver of the stepper motor offered by the Elegoo Parts Kit makes our code much simpler and more concise.
Part B Day time / Night time Detect
We use a photoresistor to detect the light. In Day mode, whenever the ultrasonic module detects a person, the Arduino controls the motor into the unlocking region, and 2 seconds later, the gate is automatically closed. Therefore, anyone has the access to the building or the room in the daytime. In the Night mode, a password is needed to unlock the door, and the ultrasonic module is disabled. Initially we planned to use RFID module to identify the guest, whereas we considered that holding a key is not so convenient. Also the key might be lost which brings troublesome issues to us, including making a new key, changing the RFID access etc. In the final design, a membrane keypad is used to realize the password-required authorization. That is to say, the gate would only open for limited individuals.
Part C Ultrasonic Module
The ultrasonic module can be used in motion detecting. When the Echo signal changes, this implies a person in front of the door. The motion sensor is also useful, and the logic here is straightforward here. The ultrasonic module receives the echo sound signals, and the motion sensor utilizes a Fresnel lens to collect reflected inferred signal. Considering that we don’t want a large angle range, for example, people pass by the gate should not alarm the sensor, the ultrasonic module seems to be better here since it only has a 15 degrees detecting angle. Then the MCU would control the motor to unlock the door if the sensor detects a person. Part D Password
The password requirement is realized by the membrane keypad. The membrane keypad is actually a switch array. By sending HIGH to LOW signals to each column and row in sequence, the exact pressed button could be detected. We basically set a 3-digit password now, and the password changing functionality is also designed and coded. In case the ultrasonic module breaks down, we make the password keypad still available at daytime, so the reliability of the system is enhanced.
The system realizes the unlocking and locking control of a gate. The overall system can be divided into 4 parts, the stepper motor, the light detecting module, the ultrasonic module and the membrane keypad.
The stepper motor unlocks and locks the gate by rotating 180 degrees clockwise and counterclockwise, respectively. A precise angle of 180 degrees is assured by carefully calculating the pulses needed to drive the stepper motor. A stepper motor driver is needed to connect the stepper motor with the Arduino.
We use a photoresistor to detect the environmental light and decide whether it’s day mode or night mode. Since the output signal of a photoresistor is analog, and ADC module should be included into our design. Therefore, the output of photoresistor is connected directly with the GPIO A0 port of the Arduino.
In the daytime mode, any motion in the detection range of the ultrasonic module could trigger the unlocking of the gate. Then 2 seconds later, the gate is automatically locked, so guests don’t have to close it manually. If the ultrasonic module doesn’t work, guests could still go into the room using a password, which means the membrane keypad control is always on.
In the nighttime mode, a password is needed to open the door. We temporarily set a 3-digit password, and a password-changing functionality is also designed to strengthen its security.
Overall we successfully accomplished a majority of our goals for this project. Starting from stepper motor position control, we further included day time and night time mode detections, ultrasonic and membrane controlling in our project. We learnt a lot from this project. We applied the techniques we learnt from course assignment into our project, including photoresistor and ultrasonic sensor. These consolidated our knowledge learnt from class. With the knowledge we learnt, these two parts went smoothly. Then we furthered into new techniques, stepper motor position control and membrane control. We met some challenges during these parts. Our abilities to conquer difficulties were also improved during this project. We faced problems finding available libraries for the membrane module. We started from understanding the basic controlling strategy and wrote our own code to successfully control the membrane module. This is the part we are most proud of in our project. When facing problems, we did not give up easily and started to look for solutions from the beginning. We encountered some obstacles we did not anticipated before. While we planned on adding digital display to improve completeness of our project, we realized that our available pins in Arduino are limited. Therefore we had to abandon this part. If we planned this up earlier enough, we could have added another Arduino for extra pins. In the future we could improve our projects by finishing up the abandoned parts. We could also add other figures to the unlocking and locking system to make this project more completed. For example, we could add another safety module when the gate is automatically locked, we could force the gate stop locking when we detect a person’s entering.
Datasheet of Ultrasonic Module https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf Datasheet of Stepper Motor https://drive.google.com/file/d/1FOS7VfAkripnC4SUJKarw4o6F_4azT96/view