{"id":52285,"date":"2026-11-01T10:50:51","date_gmt":"2026-11-01T10:50:51","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/"},"modified":"2026-11-01T10:50:51","modified_gmt":"2026-11-01T10:50:51","slug":"led-traffic-light-module","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/","title":{"rendered":"LED Traffic Light Module"},"content":{"rendered":"<body><p><\/p>\n<h2>What it does<\/h2>\n<p>The traffic light module puts a red, a yellow and a green LED on one small board with a shared ground connection, so three separate outputs can be wired with four jumper wires instead of six wires and three loose resistors.<\/p>\n<p>It is the clearest way to learn the step that every output project depends on: deciding which pin is on, which is off, and for how long. A traffic light is a good first example because the rules are already familiar, and because a mistake is obvious rather than subtle. If two lamps are lit at once, you can see it.<\/p>\n<p>The same pattern drives status indicators on a machine, a battery-level display, or any panel that has to show one state at a time.<\/p>\n<h2>Before you begin<\/h2>\n<h3>Required parts and tools<\/h3>\n<ul>\n<li>An Arduino Uno or compatible board, already set up.<\/li>\n<li>One LED traffic light module.<\/li>\n<li>Four female-to-male jumper wires, or four male-to-male wires and a breadboard.<\/li>\n<li>A USB data cable.<\/li>\n<\/ul>\n<h3>The board Siratek sells<\/h3>\n<p>The module on the Siratek product page has <strong>four pins<\/strong>, marked <code>R<\/code>, <code>Y<\/code>, <code>G<\/code> and <code>GND<\/code> on the silkscreen, and a small surface-mount resistor beside each LED.<\/p>\n<p>Two things follow, and they make this simpler than many tutorials suggest.<\/p>\n<ul>\n<li>The three LEDs share one ground connection. A signal pin set <code>HIGH<\/code> lights its lamp, and <code>LOW<\/code> turns it off. There is no <code>VCC<\/code> pin and nothing to connect to <code>5V<\/code>.<\/li>\n<li>The current-limiting resistors are already on the board. <strong>Do not add your own.<\/strong> Extra resistance in series will only make the lamps dim.<\/li>\n<\/ul>\n<p>Boards print the labels in different orders, and the module can be inserted either way round. Match the printed label to the wire rather than counting positions in the row.<\/p>\n<p>If you have a different module from elsewhere with a fifth <code>VCC<\/code> pin, it is the common-anode kind: the anodes are tied to <code>VCC<\/code>, and every <code>HIGH<\/code> and <code>LOW<\/code> in the sketch below swaps over.<\/p>\n<h3>Safety and electrical notes<\/h3>\n<ul>\n<li>An Uno I\/O pin is rated for about <strong>20 mA<\/strong>. The sketch below lights one lamp at a time, which keeps the board well inside that.<\/li>\n<li>If you modify the sketch to light several lamps together, remember the limit applies to the total drawn through the ground return as well as to each pin.<\/li>\n<li>Make every connection with the USB cable unplugged, then plug in.<\/li>\n<li><code>GND<\/code> is not optional. Without it the circuit has no return path and the lamps behave unpredictably rather than simply staying off.<\/li>\n<\/ul>\n<h2>Pin reference<\/h2>\n<table>\n<thead>\n<tr>\n<th>Pin or label<\/th>\n<th>Connect to<\/th>\n<th>Purpose<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>GND<\/code><\/td>\n<td>Uno <code>GND<\/code><\/td>\n<td>Common ground return<\/td>\n<td>Required, connect this one first<\/td>\n<\/tr>\n<tr>\n<td><code>R<\/code><\/td>\n<td>Uno <code>D8<\/code><\/td>\n<td>Red lamp<\/td>\n<td><code>HIGH<\/code> lights it on a common-ground module<\/td>\n<\/tr>\n<tr>\n<td><code>Y<\/code><\/td>\n<td>Uno <code>D9<\/code><\/td>\n<td>Yellow lamp<\/td>\n<td>Sometimes labelled <code>A<\/code> for amber<\/td>\n<\/tr>\n<tr>\n<td><code>G<\/code><\/td>\n<td>Uno <code>D10<\/code><\/td>\n<td>Green lamp<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>VCC<\/code><\/td>\n<td>nothing<\/td>\n<td>Not present on this module<\/td>\n<td>A board that has one is the common-anode kind<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Pins 8, 9 and 10 are ordinary digital pins with nothing special about them. They are chosen here because they are grouped together on the header and keep clear of <code>D0<\/code> and <code>D1<\/code>, which carry the USB serial traffic.<\/p>\n<h2>Wiring steps<\/h2>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg\" alt=\"Traffic light module wired to an Arduino Uno, R to pin 8, Y to pin 9, G to pin 10 and GND to ground\" loading=\"lazy\"><figcaption>Four wires and nothing else. The resistors beside each LED are already fitted.<\/figcaption><\/figure>\n<ol>\n<li>Unplug the USB cable from the Uno.<\/li>\n<li>Connect the module\u2019s <code>GND<\/code> pin to any <code>GND<\/code> pin on the Uno.<\/li>\n<li>Connect <code>R<\/code> to digital pin <code>8<\/code>.<\/li>\n<li>Connect <code>Y<\/code> to digital pin <code>9<\/code>.<\/li>\n<li>Connect <code>G<\/code> to digital pin <code>10<\/code>.<\/li>\n<li>Check each wire against the printed label on the module, following it with a finger from the module pin to the Uno pin. A wire one position out is the single most common fault here.<\/li>\n<li>Plug the USB cable back in.<\/li>\n<\/ol>\n<p>Nothing should light up yet. The pins are still in their default state, and whatever sketch was previously on the board is now running.<\/p>\n<h2>Software and libraries<\/h2>\n<p>No library is required. <code>pinMode()<\/code>, <code>digitalWrite()<\/code> and <code>delay()<\/code> are all part of the Arduino core, and the Serial Monitor output uses nothing extra.<\/p>\n<h2>Minimal working example<\/h2>\n<p>The helper function turns every lamp off before turning one on. That single habit is what guarantees you can never show two colours at once, however the timing is later changed.<\/p>\n<pre><code>\/\/ Siratek: LED traffic light module.\n\/\/ Cycles green, yellow and red, and reports each phase over USB.\n\nconst int redPin = 8;\nconst int yellowPin = 9;\nconst int greenPin = 10;\n\n\/\/ Phase durations in milliseconds. These are the numbers to change.\nconst unsigned long greenTime = 5000;\nconst unsigned long yellowTime = 2000;\nconst unsigned long redTime = 5000;\n\nvoid setup() {\n  pinMode(redPin, OUTPUT);\n  pinMode(yellowPin, OUTPUT);\n  pinMode(greenPin, OUTPUT);\n\n  Serial.begin(9600);\n  Serial.println(\"Siratek: traffic light starting.\");\n}\n\n\/\/ Clears all three lamps, lights one, then holds it.\nvoid showOnly(int pin, const char *name, unsigned long holdFor) {\n  digitalWrite(redPin, LOW);\n  digitalWrite(yellowPin, LOW);\n  digitalWrite(greenPin, LOW);\n\n  digitalWrite(pin, HIGH);\n  Serial.println(name);\n  delay(holdFor);\n}\n\nvoid loop() {\n  showOnly(greenPin, \"green\", greenTime);\n  showOnly(yellowPin, \"yellow\", yellowTime);\n  showOnly(redPin, \"red\", redTime);\n}<\/code><\/pre>\n<p>Two things you may need to change. If your wiring differs, edit <code>redPin<\/code>, <code>yellowPin<\/code> and <code>greenPin<\/code> to match. If you have a five-pin common-anode module, swap the <code>LOW<\/code> and <code>HIGH<\/code> values inside <code>showOnly()<\/code>.<\/p>\n<h2>Expected result<\/h2>\n<p>One lamp at a time, repeating: green for five seconds, yellow for two, red for five.<\/p>\n<p>With the Serial Monitor open at <strong>9600 baud<\/strong> you should see the phase names appear in step with the lamps:<\/p>\n<pre><code>Siratek: traffic light starting.\ngreen\nyellow\nred\ngreen<\/code><\/pre>\n<p>The serial output is the useful part when something looks wrong. If the names are cycling at the right pace but the lamps are not following, the fault is in the wiring rather than the sketch.<\/p>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Nothing lights at all<\/td>\n<td><code>GND<\/code> not connected<\/td>\n<td>Connect the module <code>GND<\/code> to an Uno <code>GND<\/code> pin<\/td>\n<\/tr>\n<tr>\n<td>All three lit, going dark one at a time<\/td>\n<td>Common-anode module driven as common-ground<\/td>\n<td>Connect <code>VCC<\/code> to <code>5V<\/code> and swap <code>HIGH<\/code> and <code>LOW<\/code> in <code>showOnly()<\/code><\/td>\n<\/tr>\n<tr>\n<td>Lamps in the wrong order<\/td>\n<td>Signal wires crossed<\/td>\n<td>Follow each wire from the module label to the pin number<\/td>\n<\/tr>\n<tr>\n<td>One colour never lights<\/td>\n<td>That wire, or that LED<\/td>\n<td>Move the working green wire onto the dead pin to tell which<\/td>\n<\/tr>\n<tr>\n<td>Lamps very dim<\/td>\n<td>Module has no onboard resistors and is on a weak supply, or board is 3.3 V<\/td>\n<td>Check for the three resistors, and confirm the board is a 5 V Uno<\/td>\n<\/tr>\n<tr>\n<td>One lamp glowed brightly once, then nothing<\/td>\n<td>No series resistor, LED destroyed<\/td>\n<td>Fit 220-330 ohm resistors before replacing the module<\/td>\n<\/tr>\n<tr>\n<td>Lamps flicker or cut out<\/td>\n<td>Loose jumper or breadboard contact<\/td>\n<td>Reseat every wire with the cable unplugged<\/td>\n<\/tr>\n<tr>\n<td>Serial shows phases, lamps dead<\/td>\n<td>Wired to the wrong pins<\/td>\n<td>Confirm <code>8<\/code>, <code>9<\/code>, <code>10<\/code> against the sketch<\/td>\n<\/tr>\n<tr>\n<td>Upload fails after wiring<\/td>\n<td>Something on <code>D0<\/code> or <code>D1<\/code><\/td>\n<td>Move it to another pin<\/td>\n<\/tr>\n<tr>\n<td>Two lamps lit together<\/td>\n<td><code>showOnly()<\/code> edited, or a short between pins<\/td>\n<td>Restore the three <code>LOW<\/code> lines, then check for touching wires<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Getting Started with Arduino Uno<\/em>, if the upload or the Serial Monitor gave you trouble here.<\/li>\n<li><strong>Related product:<\/strong> the tactile push button, which turns this fixed cycle into one that responds to a pedestrian.<\/li>\n<li><strong>Next project:<\/strong> add the passive buzzer and sound a short tone during the crossing phase.<\/li>\n<\/ul>\n<p>Two worthwhile extensions once it runs. Many countries show red and amber together before green; adding that phase means lighting two lamps at once, so work out the current first. And <code>delay()<\/code> stops the whole program while it waits, so a button pressed during a phase is ignored. Rewriting the cycle around <code>millis()<\/code> is the standard fix, and it is what the push button tutorial builds towards.<\/p>\n<h2>Sources and attribution<\/h2>\n<p>All text, wiring guidance and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>Arduino core reference for <code>pinMode()<\/code>, <code>digitalWrite()<\/code> and <code>delay()<\/code>.<\/li>\n<li>Arduino Uno R3 documentation and ATmega328P datasheet for the per-pin current limit.<\/li>\n<\/ul>\n<p>Module pin labelling varies between suppliers, so the two wiring styles above are described from the labels on the board rather than copied from any manufacturer\u2019s document. No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>The traffic light module puts a red, a yellow and a green LED on one small board with a shared ground connection, so three separate outputs can be wired with four jumper wires instead of six wires and three loose&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52285","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>LED Traffic Light Module - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LED Traffic Light Module - siratek\" \/>\n<meta property=\"og:description\" content=\"The traffic light module puts a red, a yellow and a green LED on one small board with a shared ground connection, so three separate outputs can be wired with four jumper wires instead of six wires and three loose...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/\",\"name\":\"LED Traffic Light Module - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-traffic-light-module-wiring.svg\",\"datePublished\":\"2026-11-01T10:50:51+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-traffic-light-module-wiring.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/led-traffic-light-module-wiring.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/led-traffic-light-module\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"LED Traffic Light Module\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LED Traffic Light Module - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/","og_locale":"en_US","og_type":"article","og_title":"LED Traffic Light Module - siratek","og_description":"The traffic light module puts a red, a yellow and a green LED on one small board with a shared ground connection, so three separate outputs can be wired with four jumper wires instead of six wires and three loose...","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/","name":"LED Traffic Light Module - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg","datePublished":"2026-11-01T10:50:51+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/led-traffic-light-module-wiring.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/led-traffic-light-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"LED Traffic Light Module"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52285\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52285"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}