The Traffic Light

The ACM possesses a traffic light with red, yellow, and green LED aspects. It needs wall power (used for the lights themselves) and USB (for the control circuitry).

Warning

Do not allow either cable to be pulled. Very bad things could happen to the circuitry inside!

The circuitry is stuffed behind the red light; some wiring goes through a demarc behind the yellow light.

TODO: add circuit diagram

Warning

Remove power before opening the light. Full wall voltage exists inside!

Power to the lights is switched using a four-relay board; the relays are red, yellow, green, and unconnected, respectively. The relays are controlled from an AVR, which speaks serial-over-USB to allow control of the lights.

The software on the AVR performs a lamp test upon reset, then waits for characters to arrive over the serial line at 9600 baud 8N1. The protocol is trivial:

  • R (upper case) turns on the red light.
  • Y (upper case) turns on the yellow light.
  • G (upper case) turns on the green light.
  • Any of the above in lower case turn off the corresponding light.
  • A/a (for “arrow”) do the same with the fourth relay, in case something is connected to it in the future.
  • Changing the state of a light does not affect the other lights. Any combination is allowed.

The serial device will appear as /dev/ttyACM# (with # probably zero) on the system the USB cable is plugged into. Note that opening the device under most circumstances will pulse one of the flow control lines at the far end, causing the AVR to reset, lamp-test, and forget the preexisting light state, so the light should be spoken to by a daemon that keeps the file descriptor open continuously.