Automatic Gate Barrier
- Understand how to use the "digital input/output" and "servo" nodes correctly.
- Understand how to connect the infrared obstacle-avoiding sensor, servo, and Arduino101 and use them correctly to create an automatic gate barrier.
- Understand how the infrared obstacle-avoiding sensor and servo works.
With the advancements in technlogy, cars are becoming more and more popular in our everyday lives. In many societies, a car is needed in order to get around. A common annoyance, especially at airports, can be the those darn automatic gate barriers and the speed in which they operate (Picture 1). You'll typically see one when leaving the parking garage or a city parking lot.
What about possibly creating a device that would simply raise the barrier automatically once it detects a car? This is what we'll be discussing in this particular passage.
Picture 1: Automatic Gate Barrier
The key aspects of an automatic gate barrier are:
- Detect the cars
- Trigger the servo to raise the barrier once a car is detected. After 2 seconds, restore the original position of the barrier.
We use the infrared obstacle-avoiding sensor made by DFRobot to detect the cars and trigger the servo. The project analysis is shown in the figure below.
Figure 1: Project Analysis of the Automatic Gate Barrier
Automatic Gate Barrier
Detect the cars, if so, trigger the servo to raise the barrier once a car is detected. After 2 seconds, restore the original position of the barrier.
Infrared Obstacle-avoiding Sensor, Servo
A. Infrared Obstacle-Avoiding Sensor
The Infrared Obstacle-Avoiding Sensor is a photoelectric sensor that can both transmit and receive signals as Picture 2 suggests. The light behind the sensor flickers while the digital signal trasmits. Its detection range can be adjusted based on your preferance. This sensor type is capable of long-distance detections, less interferances from visible light, and various other features. They can be used extensively in many different aspects, including robot obstacle avoidance, and digital interactive installation projects etc.
Picture 2: Infrared Obstacle-Avoiding Sensor
The Servo is an automatic control system which consists of a DC motor, a gear reduction unit, a sensor, and a control circuit. It sets up the angle of rotation of the output shaft based on the transmitted signal. Servos usually have a maximum angle rotation of 180 degrees.
Normal DC motors cannot relay the information back of the rotation angle, however, the Servo can. They are also very different in their usage: DC motors are used to provide power while the Servo is used to control the rotation angle of some objects (like joints of robots or of a camera). In this case, the speed of the rotation is decided by the time that the Servo needs to rotate to 60 degrees. In most cases, the speeds are between 0.11/60° and 0.21s/60°.
Picture 3: Servo
Connect the Arduino101, the servo, and the Infrared Obstacle-Avoiding Sensor, shown in Figure 4.
Connect the Servo to digital output (D11) and Infrared Obstacle-Avoiding Sensor to digtital input(D5)
Picture 4: Connection of the Automatic Gate Barrier
To understand the trigger of the servo (once a car is detected and to restore its original position after 2 seconds), we need to use the "delayed" node, shown in Picture 5.
Picture 5: Programming of the Automatic Gate Barrier
The transmission of the program data is divided into two parts:
- Trigger the Infrared Obstacle-Avoiding Sensor to send “75” to the Servo once a car is detected, resulting in the Servo turning 75 degrees.
- Send “0” to the Servo after 2 seconds once no cars are detected, resetting the Servo.
C. Set Up
For the Infrared Obstacle-Avoiding Sensor to work in real-time, we need to add a StartSwitch node.
Picture 6: Setting up the StartSwitch node
To determine whether a car is nearby, we need to use the DFInfraredAvoid node. This time, we set the switch to D5.
Picture 7: Setting up the DFInfraredAvoid node
Once the Infrared Obstacle-Avoiding Sensor sends the signal, we need to interpret the data. If the signal is "1", we trigger the Servo, otherwise, we delay the progress. In order to do this, we need to add a "Decision node" shown in the picture below.
Picture 8: Setting up the Switch node
The Servo is essential to any Automatic Gate Barrier. Next, we need to set the Servo node. This time, we set the Servo's digital pin to 11, shown in Picture 9.
Picture 9: Setting up the DFServo node
After triggering the Infrared Obstacle-Avoiding Sensor, we need it to send the rotation angle to the Servo. It needs to draw into “transfer node” and set the data as Picture 9 suggested.
Picture 10: Setting up the Chage node
In order to automaticlaly restore the Servo's position after 2 seconds, we need to add a "delay node."
Picture 11: Setting up the Delay node
We can also add a debug node to receive the signal from all the mentioned nodes, allowing you to debug the entire system.
Picture 12: Setting up the Debug node
By setting up all the nodes and connecting them, we have completed the programming for our Automatic Gate Barrier!
Click "Deploy" and you can then begin to test the functionality of our new Automatic Gate Barrier. Once a car is detected, the end of the Infrared Obstacle-Avoiding Sensor shines (if the connection is incorrect, the light will continue to shine), the Servo turns and after 2 seconds, the Servo's position is restored. If it is not working as expected, ask your friends or simply post your question on our forums!
Last but not least, don't forget to share your work and learning process with your friends and colleagues!
The rotation angle of the Servo is fixed, offering a relatively simple function. Do you think we can control the angle with a knob sensor or something else? Try it yourself and tell us some of your ideas!
Ⅵ Extended reading
How Infrared Obstacle-Avoiding Sensor Works?
Infrared Obstacle Avoidance sensors are cheap, small sensors often used in robots, and maker project to detect objects near the sensor.
The Infrared sensors work by sending an infrared light with some frequency, and then detecting if some of the light has reflected back to the sensor. The most common ones have a digital output indicating if object has been detected. Many of them have the option to be enabled or disabled.