Parking barrier
A parking barrier: an MG996R arm, a traffic light and an HC-SR04 on one post, and cars that drive up the lane and wait at the line.
Send a car and it stops 8 cm from the post until the arm is up, then drives on under it and out of the lane.
Pins
| Pin | What it does |
|---|---|
TRIG, ECHO |
The HC-SR04's trigger and echo. |
R Y G |
The traffic light's three LEDs, each through 220 ohm to GND. |
ARM |
The MG996R's signal. |
V+ |
The MG996R's own supply, 4.8 to 7.2 V. |
VCC, GND |
5 V for the ranger. GND is everything's ground. |
The ranger, the light and the servo are the parts a home build uses, on the pins they have on the bench, so a sketch written for the loose parts runs the barrier unchanged.
How it works
Press CAR on the barrier and a car starts 120 cm down the lane at 30 cm/s. If the arm is down it brakes and stops with its nose 8 cm from the post; once the arm is up (80 degrees or more) it drives on under it and out of the lane. Cars sent while one is in the lane queue behind it, up to three.
The ranger measures the gap from the post to the front of the car: the echo is 58 us a centimeter at 20 C, after a 460 us burst. With no car in front of it, or one already past the post, it reads nothing in range, the 38 ms echo.
The arm is 0 degrees down across the lane and 90 straight up. On the MG996R it takes 0.17 s per 60 degrees at 4.8 V and 0.14 s at 6 V, and does not move under 4 V.
What the model gets right
- The ranger is the HC-SR04 model: its timing, its 60 ms cycle and its timeout.
- The light is the traffic light module's LEDs and resistors.
- The arm is the MG996R model, its speed following its supply.
- Everything is deterministic: every car behaves the same way.
What it does not model
- The arm coming down on a car. A sketch that waits for the lane to be clear for a couple of seconds, as a real barrier does, never has to find out.
- The ranger's cone and noise, and drivers who do not stop.