There is a railroad crossing near my house and my 2yr old likes to watch the gate arm go up and down to let the train/traffic cross. As much as I’d love to stay with him on that crossing all day long 🙂 I decided it would be much easier to build a smaller version of the gate arm at home for him to play with.
1 x Arduino Pro Mini
3 x RGB LEDs
2 x 100 Ohm resistors
1 x Servo motor
1 x Sharp IR sensor
The operation is pretty simple, when there is no obstacle (car) in front of the gate, the arm is in horizontal position. When obstacle is detected in front of the gate, it signals by flashing green lights that it is going to vertical position in order to let the traffic go through. It stays up as long as there are obstacles detected in front of the gate. Once there are no obstacles in front of the ramp it signals with flashing red lights that it is going to close and then goes into the horizontal position.
You can check out the code at my GitHub repo:
If you liked this blog post I’d appreciate if you followed me on Twitter