Homemade build traffic light in the office

Background


In connection with the planned transition to continious integration and reading a couple of articles about traffic lights in the office, I also wanted to get hold of such a warm lamp device. As a result, it turned out to be not at all warm and not tube-like, but more on that later.

Those who are interested in this topic already know that the price of a new traffic light fluctuates around $ 500. Attempts to find a used decommissioned device were unsuccessful. Both options could not please the budget and the soul of two enthusiasts from the office, so it was decided to make the traffic light itself.

Idea


In principle, there is nothing complicated in the design of a traffic light, but what kind of layout was still made. So it was easier to imagine what needs to be cut and how best to do it.

image

Before making a layout on one of the sites with announcements, we were lucky to find glass from a Soviet traffic light. This was a huge relief, as the original glass lends authenticity to the construction better than nothing. Accordingly, the dimensions of the case were dictated by the size of the glasses, as well as the dimensions of internal components such as power supplies, wiring, etc.

The main “brain” was raspberry pi for several reasons. The first is its presence after previous experiments with the “raspberry”, the second is the simplicity of implementing traffic control from the outside, the installation of various kinds of software, wifi, etc.

Body


It all started of course with the body. For its manufacture, PVC plastic was used which is used for the manufacture of outdoor advertising. It is very easy to process and in combination with super glue at the exit gives a rather solid construction. Plastic with cutting appropriate sizes was ordered from an advertising agency. The accuracy of cutting turned out to be slightly worse than expected, so after gluing the body I had to work pretty hard with plastic putty and emery. As a result, we got such a case here.

image

Plastic turned out to be so malleable that it was easier to make visors than anyone could have imagined. The carved details of the visors were thrown into boiling water, and then bent on a two-liter jar before cooling. Yes, yes, the diameter of the two-liter can was the same as the glass. This unification was in the USSR!

So far, simply by applying glass, one could already clearly see the future traffic light, although even at the stage of the hull it seemed that nothing good could come of with this idea.

image

After painting in black “traffic light” color, everything began to look even more wonderful. Camouflage cords were also glued to cover the glass fasteners and give the structure a more complete look.

image

Electronics


For the sake of safety, reducing energy consumption and a number of other reasons, LEDs were chosen as the light source. Only 27 pieces, 9 per color. For them, 27 holes were drilled in the housing, respectively.

image

For ease of repair and installation of LEDs, they were placed on plastic matrices with the placement coinciding with the holes in the housing.

image

They are easily installed and removed in case one of the LEDs lights up. To control the logic, the GPIO pins on raspberry pi are used, respectively, as a control logic, a board was made with three relays controlled by a 3V voltage and a switching 12V, which are fed to the LED matrix.

image

At the testing stage, before the final assembly, the assembly looked something like this.

image

Everything is “thrown” into the case and a temporary 220V power cord is attached because there was no cord of sufficient length at hand at the time of assembly. Inside there are also two power supplies. One 12V for powering the LEDs, the second unit with a USB port for raspberry pi.

image

Software


For ease of control, a lighttpd server with mod_fcgi for python was installed externally. Thus, you can control the mode simply from the browser. So it was convenient to indulge yourself. Later, code was written for Jenkins that polls it and accordingly changes the status of the traffic light. Python was not chosen by chance, with its help it is quite easy to cope with managing GPIO pins on raspberry using a set of wiringpi.com libraries .

A simple web script code for management, which was later replaced by the one described above.

#!/usr/bin/pythonRoot
# Bring in the libraries
import RPi.GPIO as G
from flup.server.fcgi import WSGIServer
import sys, urlparse, time
# GPIO lights map
light_r = 4
light_y = 17
light_g = 22
# Set up our GPIO pins
G.setmode(G.BCM)
G.setup(light_r, G.OUT)
G.setup(light_y, G.OUT)
G.setup(light_g, G.OUT)
# Offs all lights
def offLights():
    G.output(light_r, False)
    G.output(light_y, False)
    G.output(light_g, False)    
# Function which is called for each http request we receive
def app(environ, start_response):
    # start our http response
    start_response("200 OK", [("Content-Type", "text/html")])
    # look for inputs on the URL
    i = urlparse.parse_qs(environ["QUERY_STRING"])
    yield (' ') # flup expects a string to be returned from this function
    # if there's a url variable named 'q'
    if "mode" in i:
        if i["mode"][0] == "red":
            offLights()
            G.output(light_r, True)
        elif i["mode"][0] == "yellow":
            offLights()
            G.output(light_y, True)
        elif i["mode"][0] == "green":
            offLights()
            G.output(light_g, True)
        elif i["mode"][0] == "off":
            offLights()        
#Run app
WSGIServer(app).run()


Expenses


It took about a week for two people to work, one hour a day after work. For the money:
Raspberry pi model b$ 50
PVC plastic for cut case$ 15
Matte black paint$ 10
Power supplies$ 10
Relays, LEDs and other trifles$ 10
Wifi whistle for raspberry$ 10
Glass$ 7
Putty$ 5
 Total: $ 117

Conclusion


Let's start with the video in demo mode.



As can be seen from the video, the cold glow of the LEDs in combination with our glass gave a bluish tint. Now we are considering the correction options, as long as maintainability has been incorporated into our design.
Agree the difference in the budget is enormous, the enthusiasm is satisfied and the result is more than satisfactory. The result was, though not a warm lamp but a cold LED, but still a traffic light, which in the near future I hope will begin to fulfill its purpose. The transition to continious integration is not yet complete.

Good luck to everyone, and fewer red ones at build traffic lights!

Also popular now: