{"id":528,"date":"2023-10-23T12:00:56","date_gmt":"2023-10-23T11:00:56","guid":{"rendered":"http:\/\/robert.vanyi.org\/en\/?p=528"},"modified":"2024-05-09T11:43:50","modified_gmt":"2024-05-09T10:43:50","slug":"railway-crossing-lights-with-the-tlc555","status":"publish","type":"post","link":"https:\/\/robert.vanyi.org\/en\/archives\/528","title":{"rendered":"Railway crossing lights with the TLC555"},"content":{"rendered":"\n<p>After we successfully built a circuit to have a blinking green LED, we wanted to bring it to the next level. <\/p>\n\n\n\n<p>First step: have alternating lights. It was quite easy, as we also had a Texas Instruments <a href=\"https:\/\/www.ti.com\/product\/SN74LS04\" data-type=\"URL\" data-id=\"https:\/\/www.ti.com\/product\/SN74LS04\">SN74LS04<\/a> inverter chip, we just connected it to 5V and GND, connected the output signal of the TLC555 to one of the inverters in the 74LS04 and got the inverted signal on the next pin, which then we could simply connect to another LED.<\/p>\n\n\n\n<p>Next step: add a switch so select between <code>stop<\/code> (red) and <code>go<\/code> (white).  No big thing, right? Add a switch, and then the output (<code>clock<\/code>) of the TLC555 can go to the red (as before) or to the white LED. Simple. And does not work. Remember the inverter? It inverts the input for the first red LED (<code>red<sub>1<\/sub><\/code>) to get the signal for the second red LED (<code>red<sub>2<\/sub><\/code>), so as soon as we switch on the white LED (<code>white<\/code>) the first red will be permanently off, so the second will be permanently on.<\/p>\n\n\n\n<p>Luckily we also had the Texas Instruments <a href=\"https:\/\/www.ti.com\/product\/SN74LS08\">SN74LS08<\/a> with 4 AND gates, so we could improve the logic. Put the switch to 5V instead of clock, and then AND the white state with the clock to get the white LED and the red state with the clock \/ inverted clock to get the two red LEDs. Basically the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>white = go AND clock\nred<sub>1<\/sub>  = stop AND clock\nred<sub>2<\/sub>  = stop AND NOT clock <\/code><\/pre>\n\n\n\n<p>It should work, right? Well, no. If the switch is set to go then the AND gate will get 5V plus the clock signal to get the white LED input, but if the switch is set to stop, then the go line will be open, and in this case the output of the AND gate is not defined.<\/p>\n\n\n\n<p>To solve it, we turned around the switch: not to switch 5V between stop and go, but switch go between 5V and GND. This way go was always in a defined state, and to get stop we just inverted go. This way we get our nice railway crossing light.<\/p>\n\n\n\n<p>Of course we have set it up with a bunch of control lights: two LEDs blinking alternately to show the clock signal, as well as an addition red and white LEDs to show the state of the switch.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/crossing_lights.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/crossing_lights.png\" alt=\"breadboard with the railway crossing light simulator\" class=\"wp-image-530\" srcset=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/crossing_lights.png 800w, https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/crossing_lights-300x225.png 300w, https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/crossing_lights-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><figcaption class=\"wp-element-caption\">completed circuit<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic-1024x470.png\" alt=\"\" class=\"wp-image-532\" srcset=\"https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic-1024x470.png 1024w, https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic-300x138.png 300w, https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic-768x352.png 768w, https:\/\/robert.vanyi.org\/en\/wp-content\/uploads\/2023\/10\/railway-crossing-schematic.png 1506w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">schematics<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>After we successfully built a circuit to have a blinking green LED, we wanted to bring it to the next level. First step: have alternating lights. It was quite easy, as we also had a Texas Instruments SN74LS04 inverter chip, we just connected it to 5V and GND, connected the output signal of the TLC555 &hellip; <a href=\"https:\/\/robert.vanyi.org\/en\/archives\/528\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Railway crossing lights with the TLC555<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76],"tags":[74,72],"class_list":["post-528","post","type-post","status-publish","format-standard","hentry","category-electronics","tag-breadboard","tag-electronics"],"_links":{"self":[{"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/comments?post=528"}],"version-history":[{"count":0,"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/posts\/528\/revisions"}],"wp:attachment":[{"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/media?parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/categories?post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robert.vanyi.org\/en\/wp-json\/wp\/v2\/tags?post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}