{"id":82378,"date":"2025-01-15T08:13:51","date_gmt":"2025-01-15T13:13:51","guid":{"rendered":"https:\/\/www.engineersgarage.com\/?p=82378"},"modified":"2025-02-24T12:55:08","modified_gmt":"2025-02-24T17:55:08","slug":"arduino-based-traffic-light-system-for-four-way-crossroad","status":"publish","type":"post","link":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/","title":{"rendered":"How to design an Arduino-based traffic light system"},"content":{"rendered":"<p>Traffic light systems are important signaling devices that regulate the flow of vehicles and pedestrians at intersections, crosswalks, and other critical areas. These systems use three primary lights \u2014 red, yellow (amber), and green \u2014 to manage traffic effectively and <a href=\"https:\/\/www.engineersgarage.com\/how-to-build-a-smart-system-using-arduino-that-alerts-of-driver-fatigue\/\">ensure safety<\/a>.<\/p>\n<p>In this project, we&#8217;ll create a traffic light system for a four-way intersection using an Arduino microcontroller, <a href=\"https:\/\/www.engineersgarage.com\/how-to-build-an-ir-remote-operated-rgb-led-strip-using-arduino\/\">RGB LEDs<\/a>, and an MAX7219 IC-based 7-segment display board. This project aims to replicate real-world traffic light operations, providing a functional and educational model of a standard traffic control system.<\/p>\n<h3>Components<\/h3>\n<ol>\n<li>Arduino MEGA x1<\/li>\n<li>7-Segments x8<\/li>\n<li>MAX7219 IC x1<\/li>\n<li>RGB LEDs x4<\/li>\n<li>Breadboard x1<\/li>\n<li>Jumper or connecting wires<\/li>\n<\/ol>\n<h3><strong>The traffic light system<\/strong><\/h3>\n<p>In this project, we&#8217;ll design a traffic light system for a four-way intersection, with each direction labeled as A, B, C, and D. The system includes red, orange (amber), and green lights, along with a timer for each direction.<\/p>\n<p>At any given time, the green light will activate for only one direction, allowing traffic to flow, while the other directions remain stopped with red lights. This setup effectively manages traffic flow, similar to real-world traffic control systems.<\/p>\n<p><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-01-Traffic-Light-System-For-4-Way-Crossroad.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82379\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-01-Traffic-Light-System-For-4-Way-Crossroad.jpg\" alt=\"\" width=\"347\" height=\"280\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-01-Traffic-Light-System-For-4-Way-Crossroad.jpg 347w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-01-Traffic-Light-System-For-4-Way-Crossroad-300x242.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-01-Traffic-Light-System-For-4-Way-Crossroad-295x238.jpg 295w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/a><\/p>\n<p>At the four-way, vehicles in intersection A are allowed to proceed first, followed by those in B, then C, and finally D. By regulating traffic in this sequence, the traffic lights follow the pattern shown in the table below, ensuring a systematic flow of vehicles and minimizing congestion at each intersection.<\/p>\n<p><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-82382\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM-1024x616.png\" alt=\"\" width=\"622\" height=\"374\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM-1024x616.png 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM-300x181.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM-768x462.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM-368x221.png 368w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.39.00\u202fPM.png 1306w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<p>Note, that the traffic light pattern repeats itself starting from the fifth step. Assuming the green light remains active for 20 seconds for each intersection and the orange light stays on for five seconds, the traffic signal operates according to the time schedule shown below.<\/p>\n<p><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-82383\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-1024x392.png\" alt=\"\" width=\"654\" height=\"250\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-1024x392.png 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-300x115.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-768x294.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-1536x588.png 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM-368x141.png 368w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.42.56\u202fPM.png 1814w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/a><\/p>\n<p>Initially, the signal for intersection B remains red for 25 seconds, for C it stays red for 50 seconds, and for D it remains red for 75 seconds. After completing the first cycle of signals for each direction, the signal follows a consistent pattern: green for 20 seconds, orange for 5 seconds, and red for 75 seconds for each way.<\/p>\n<p>With the assumption that the signal remains green for 20 seconds and orange for 5 seconds for each intersection, let&#8217;s design the full traffic light system.<\/p>\n<h3><strong>Circuit connections<\/strong><\/h3>\n<p>In this project, we&#8217;re using the MAX7219 IC-based 7-segment driver module to display the timer for each signal. The MAX7219 is an 8-digit common-cathode LED display driver that enables interfacing a microcontroller with 7-segment display units of up to 8 digits.<\/p>\n<p>The four ways of the crossroad are mapped to the 7-segment displays on the module, as shown in the image below.<\/p>\n<p><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-02-Timers-For-Traffic-Light-System.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82381\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-02-Timers-For-Traffic-Light-System.jpg\" alt=\"\" width=\"381\" height=\"213\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-02-Timers-For-Traffic-Light-System.jpg 381w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-02-Timers-For-Traffic-Light-System-300x168.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-02-Timers-For-Traffic-Light-System-368x206.jpg 368w\" sizes=\"auto, (max-width: 381px) 100vw, 381px\" \/><\/a>In the module, the data pins of the 7-segment displays are connected to the SEG A to SEG G and DP pins of the MAX7219. The common-cathode terminals of the segments are linked to MAX7219&#8217;s DIG0 to DIG7 pins. The IC&#8217;s pins 4 and 9 are connected to the ground pin, while pin 19 is connected to the 5V terminal.<\/p>\n<p>MAX7219&#8217;s pin 18 is also connected to 5V DC via an appropriate resistor. The DIN, LOAD, and CLK pins of the IC can be connected to Arduino&#8217;s\u00a0 digital I\/O pins.<\/p>\n<p>The MAX7219 communicates with the Arduino using an SPI-compatible interface. Specifically, the DIN, LOAD, and CLK pins of the IC are connected to Arduino&#8217;s pins 12, 10, and 11, respectively. The MAX7219 module is powered with 5V DC and grounded through the Arduino itself.<\/p>\n<p>The red, green, and orange signals are represented using RGB LEDs. The circuit connections for the RGB LEDs are outlined in the table below.<\/p>\n<p><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-82384\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM-1024x917.png\" alt=\"\" width=\"608\" height=\"545\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM-1024x917.png 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM-300x269.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM-768x688.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM-266x238.png 266w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Screenshot-2025-01-08-at-4.49.23\u202fPM.png 1168w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/a><\/p>\n<p>The circuit diagram for the project is shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82385\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-03-Arduino-Circuit-for-4-Way-Crossroad-Traffic-Light-System.png\" alt=\"\" width=\"640\" height=\"477\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-03-Arduino-Circuit-for-4-Way-Crossroad-Traffic-Light-System.png 640w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-03-Arduino-Circuit-for-4-Way-Crossroad-Traffic-Light-System-300x224.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/P71-03-Arduino-Circuit-for-4-Way-Crossroad-Traffic-Light-System-319x238.png 319w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h3><strong>The Arduino sketch<\/strong><\/h3>\n<p>Before making the circuit connections, upload the following sketch to Arduino MEGA.<\/p>\n<style>\n.gist-data{    height:250px; \/\/ Any height    overflow: auto;<br \/>}<\/style>\n<p><script src=\"https:\/\/gist.github.com\/Ajak58a\/555df1e903eb37d19c9988dd43f19cfd.js\"><\/script><\/p>\n<div class=\"flex max-w-full flex-col flex-grow\">\n<div class=\"min-h-8 text-message flex w-full flex-col items-end gap-2 whitespace-normal break-words text-start [.text-message+&amp;]:mt-5\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"8ef58e57-b809-4703-a296-99011d9f815b\" data-message-model-slug=\"gpt-4o\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert dark\">\n<h3><strong>How it works<\/strong><\/h3>\n<p>The 8-digit seven-segment module displays the countdown timer for the traffic signals of each direction. The timers operate according to the fixed time schedule outlined in the table above. The red, green, and orange (amber) lights for each direction are controlled using RGB LEDs.<\/p>\n<p>Initially, the RGB LED for intersection (or &#8220;way&#8221;) A lights up green for 20 seconds, followed by orange for 5 seconds. During these 25 seconds, the RGB LEDs for all other directions remain red. Subsequently, the RGB LED for intersection B turns green for 20 seconds and orange for the next 5 seconds, while the LEDs for the other ways remain red. This same sequence repeats for C and D.<\/p>\n<p>To better understand the traffic light pattern, the timer durations can be derived using the following equations:<\/p>\n<p>Let:<\/p>\n<ul>\n<li><code>a<\/code> = Duration of the green signal for the intersection or way A<\/li>\n<li><code>b<\/code> = Duration of the green signal for way B<\/li>\n<li><code>c<\/code> = Duration of the green signal for way C<\/li>\n<li><code>d<\/code> = Duration of the green signal for way D<\/li>\n<li><code>w<\/code> = Duration of the orange signal for each intersection<\/li>\n<\/ul>\n<p>Define:<\/p>\n<ul>\n<li><code>tima<\/code> = Timer value for A<\/li>\n<li><code>timb<\/code> = Timer value for B<\/li>\n<li><code>timc<\/code> = Timer value for C<\/li>\n<li><code>timd<\/code> = Timer value for D<\/li>\n<\/ul>\n<p>These equations help synchronize the timers for all directions and ensure a seamless flow of traffic.<\/p>\n<p>The signal will start off as green for intersection A and red for the other directions (B, C, and D). The timers will be initialized by the following equations at this instant.<\/p>\n<div class=\"group\/conversation-turn relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex max-w-full flex-col flex-grow\">\n<div class=\"min-h-8 text-message flex w-full flex-col items-end gap-2 whitespace-normal break-words text-start [.text-message+&amp;]:mt-5\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"27996bdd-dd16-419b-9ccd-75fc715827d3\" data-message-model-slug=\"gpt-4o\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert dark\">\n<ul>\n<li><code>tima = a + w;<\/code><\/li>\n<li><code>timb = tima;<\/code><\/li>\n<li><code>timc = tima + b + w;<\/code><\/li>\n<li><code>timd = timc + c + w;<\/code><\/li>\n<\/ul>\n<p>The timer for intersection A begins to count down while the signal remains green for a duration of <code>a<\/code> seconds and then orange for <code>w<\/code> seconds. After this initialization, as the signals change, all the timers start counting down simultaneously.<\/p>\n<p>When the timers for intersections A and B reach zero, they reset, while the timers for C and D continue counting down until their respective signals reach their turn. This synchronized countdown ensures smooth and orderly traffic flow at the intersection.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mb-2 flex gap-3 empty:hidden -ml-2\">\n<div class=\"items-center justify-start rounded-xl p-1 flex\">\n<div class=\"flex items-center\">\n<div class=\"flex\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Next, the signal turns green for intersection B while remaining red for all other directions. At this stage, the timers are initialized using the following equations:<\/p>\n<ul>\n<li><code>timb = b + w;<\/code><\/li>\n<li><code>timc = timb;<\/code><\/li>\n<li><code>timd = timb + c + w;<\/code><\/li>\n<li><code>tima = timd + d + w;<\/code><\/li>\n<\/ul>\n<p>The timer for intersection B starts counting down while the signal stays green for a duration of <code>b<\/code> seconds and orange for <code>w<\/code> seconds. After the initialization and signal change, all the timers begin their countdown.<\/p>\n<p>Eventually, the timers for intersections B and C reach zero and reset, while the timers for D and A continue counting down.<\/p>\n<p>Subsequently, the signal switches to green for intersection C while all other paths remain red. The timers are initialized at this moment using the following equations:<\/p>\n<ul>\n<li><code>timc = c + w;<\/code><\/li>\n<li><code>timd = timc;<\/code><\/li>\n<li><code>tima = timc + d + w;<\/code><\/li>\n<li><code>timb = tima + a + w;<\/code><\/li>\n<\/ul>\n<p>The timer for intersection C operates during the green signal for <code>c<\/code> seconds and orange for <code>w<\/code> seconds. After initialization and signal transition, all the timers begin their countdown. Eventually, the timers for intersections C and D count down to zero and reset, while the timers for A and B continue their countdown.<\/p>\n<p>Next, the signal turns green for intersection D while remaining red for all other directions. At this stage, the timers are initialized using the following equations:<\/p>\n<ul>\n<li><code>timd = d + w;<\/code><\/li>\n<li><code>tima = timd;<\/code><\/li>\n<li><code>timb = timd + a + w;<\/code><\/li>\n<li><code>timc = timb + b + w;<\/code><\/li>\n<\/ul>\n<p>The timer for intersection D starts running while the signal stays green for a duration of <code>d<\/code> seconds and orange for <code>w<\/code> seconds. After initialization and signal transition, all the timers begin their countdown.<\/p>\n<p>Eventually, the timers for intersections D and A reach zero and reset, while the timers for B and C continue counting down.<\/p>\n<p>This pattern repeats cyclically, ensuring a systematic and orderly traffic flow at the intersection.<\/p>\n<h3><strong>The code<\/strong><\/h3>\n<p>The Arduino sketch starts by importing the SPI library, which is essential for communication with the MAX7219 IC. Global variables are then defined to assign the pin numbers connected to MAX7219&#8217;s DIN, CLK, and LOAD pins.<\/p>\n<p>An array-type variable is initialized to store 16-bit commands for the IC. Variables are declared to hold the durations of green signals for intersections A, B, C, and D, along with the timer values for each. A count variable is introduced to manage the countdown for each second, followed by variables for the timer digits. Additional variables are defined for the RGB LEDs&#8217; pin assignments.<\/p>\n<p>A character table is stored in the flash memory of the Arduino UNO using the PROGMEM construct. This table contains the byte data required to illuminate the LED segments for displaying digits &#8220;0&#8221; to &#8220;9.&#8221;<\/p>\n<p><strong>The functions:<\/strong><\/p>\n<p>An spiTransfer() function is defined for the shiftOut() function to transfer 16-bit data to MAX7219 IC. Each 16-bit data contains two bytes: the first byte specifies the MAX7219&#8217;s address of the register, and second <span style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">byte provides the data to be written to the selected register<\/span>. Both bytes are passed as arguments to this user-defined function. Both bytes are passed as arguments to this user-defined function, enabling precise communication with the display module.<\/p>\n<p>The clearDisplay() function is defined, in which the spiTransfer() function is used to write &#8220;0x00&#8221; to all the digit registers clearing all the digits.<\/p>\n<p>A function shutdown() is defined using the spiTransfer() function to write data to MAX7219&#8217;s shutdown mode register.<\/p>\n<p>The init_7seg() function is defined to initialize the display. In this function, the MOSI, SCLK and CS pins are set to digital outputs. The CS pin is set to HIGH to select the MAX7219 on the SPI bus.<\/p>\n<p>A value of &#8220;0x00&#8221; is transferred to the display test register (with a register address of &#8220;15&#8221; or &#8220;0x0F&#8221;) using the spiTransfer() function to set the MAX7219 to normal mode.<\/p>\n<p>A value of &#8220;0x07&#8221; is transferred to scan the limit register (with a register address of &#8220;11&#8221; or &#8220;0x0B&#8221;), allowing it to use all eight digits.<\/p>\n<p>A value of &#8220;0x00&#8221; is transferred to decode mode register (with a register address of &#8220;9&#8221; or &#8220;0x09&#8221;), which selects &#8220;no decode&#8221; for all of the digits.<\/p>\n<p>A setChar() function is defined, which writes a value to MAX7219&#8217;s digit register. Both the value and digit are set as parameters of the function. This function provides a data validation for the digit number and passes the value. Then, the verified value is passed to a given digit register using the spiTransfer() function.<\/p>\n<p>The function setA(), setB(), setC() and setD() are defined to set the colors of RGB LEDs for intersections A, B, C and D respectively.<\/p>\n<p>In the setup() function, the init_7seg() and shutdown(false) functions are called. The spiTransfer(10, 8) function is called to set the intensity of the display. The display is cleared by calling the clearDisplay() function.<\/p>\n<p>Arduino&#8217;s pins are then interfaced with the RGB LEDs, which are set as digital outputs using the pinMode() function.<\/p>\n<p>The updateTimer() function is defined to countdown for all of the timers &#8212; from the initialized values at the signal change for each second. In the loop() function, the color for RGB LEDS are set according to signal matrix table and the timers are initialized for each signal change, followed by timer countdown for each second.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/drive.google.com\/file\/d\/1jJXRM3M7qOokv9eM5qxhjhjMXB4Y6s33\/preview\" width=\"640\" height=\"480\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Traffic light systems are important signaling devices that regulate the flow of vehicles and pedestrians at intersections, crosswalks, and other critical areas. These systems use three primary lights \u2014 red, yellow (amber), and green \u2014 to manage traffic effectively and ensure safety. In this project, we&#8217;ll create a traffic light system for a four-way intersection&hellip;<\/p>\n","protected":false},"author":387,"featured_media":82387,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[32,13,1871],"tags":[1175,4391,4339,2504,4606,660],"class_list":{"2":"type-post","16":"entry","17":"has-post-thumbnail"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.2 (Yoast SEO v25.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to design an Arduino-based traffic light system<\/title>\n<meta name=\"description\" content=\"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to design an Arduino-based traffic light system\" \/>\n<meta property=\"og:description\" content=\"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\" \/>\n<meta property=\"og:site_name\" content=\"Engineers Garage\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/engineersgarage\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png\" \/>\n\t<meta property=\"og:image:width\" content=\"811\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nikhil Agnihotri\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:site\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikhil Agnihotri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\"},\"author\":{\"name\":\"Nikhil Agnihotri\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\"},\"headline\":\"How to design an Arduino-based traffic light system\",\"datePublished\":\"2025-01-15T13:13:51+00:00\",\"dateModified\":\"2025-02-24T17:55:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\"},\"wordCount\":1752,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png\",\"keywords\":[\"Arduino\",\"arduinomega\",\"electronicproject\",\"traffic\",\"trafficlights\",\"video\"],\"articleSection\":[\"Arduino Projects\",\"Electronic Projects\",\"Video\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\",\"url\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\",\"name\":\"How to design an Arduino-based traffic light system\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png\",\"datePublished\":\"2025-01-15T13:13:51+00:00\",\"dateModified\":\"2025-02-24T17:55:08+00:00\",\"description\":\"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png\",\"width\":811,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.engineersgarage.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to design an Arduino-based traffic light system\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.engineersgarage.com\/#website\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"name\":\"Engineers Garage\",\"description\":\"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News\",\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.engineersgarage.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\",\"name\":\"Engineer's Garage - WTWH Media\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"width\":372,\"height\":52,\"caption\":\"Engineer's Garage - WTWH Media\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/engineersgarage\",\"https:\/\/x.com\/EngineersGarage\",\"https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\",\"name\":\"Nikhil Agnihotri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"caption\":\"Nikhil Agnihotri\"},\"url\":\"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to design an Arduino-based traffic light system","description":"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.","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":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/","og_locale":"en_US","og_type":"article","og_title":"How to design an Arduino-based traffic light system","og_description":"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.","og_url":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/","og_site_name":"Engineers Garage","article_publisher":"https:\/\/www.facebook.com\/engineersgarage","og_image":[{"width":811,"height":500,"url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png","type":"image\/png"}],"author":"Nikhil Agnihotri","twitter_card":"summary_large_image","twitter_creator":"@EngineersGarage","twitter_site":"@EngineersGarage","twitter_misc":{"Written by":"Nikhil Agnihotri","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#article","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/"},"author":{"name":"Nikhil Agnihotri","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6"},"headline":"How to design an Arduino-based traffic light system","datePublished":"2025-01-15T13:13:51+00:00","dateModified":"2025-02-24T17:55:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/"},"wordCount":1752,"commentCount":0,"publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"image":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png","keywords":["Arduino","arduinomega","electronicproject","traffic","trafficlights","video"],"articleSection":["Arduino Projects","Electronic Projects","Video"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/","url":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/","name":"How to design an Arduino-based traffic light system","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage"},"image":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png","datePublished":"2025-01-15T13:13:51+00:00","dateModified":"2025-02-24T17:55:08+00:00","description":"Learn how to design a traffic light system using Arduino, RGB LEDs, and MAX7219 for efficient traffic control.","breadcrumb":{"@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#primaryimage","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR.png","width":811,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/www.engineersgarage.com\/arduino-based-traffic-light-system-for-four-way-crossroad\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.engineersgarage.com\/"},{"@type":"ListItem","position":2,"name":"How to design an Arduino-based traffic light system"}]},{"@type":"WebSite","@id":"https:\/\/www.engineersgarage.com\/#website","url":"https:\/\/www.engineersgarage.com\/","name":"Engineers Garage","description":"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News","publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.engineersgarage.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.engineersgarage.com\/#organization","name":"Engineer's Garage - WTWH Media","url":"https:\/\/www.engineersgarage.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","width":372,"height":52,"caption":"Engineer's Garage - WTWH Media"},"image":{"@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/engineersgarage","https:\/\/x.com\/EngineersGarage","https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw"]},{"@type":"Person","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6","name":"Nikhil Agnihotri","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","caption":"Nikhil Agnihotri"},"url":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"}]}},"featured_image_src":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR-600x400.png","featured_image_src_square":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2025\/01\/Traffic-lights-ROTATOR-600x500.png","author_info":{"display_name":"Nikhil Agnihotri","author_link":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"},"_links":{"self":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/82378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/users\/387"}],"replies":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/comments?post=82378"}],"version-history":[{"count":0,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/82378\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media\/82387"}],"wp:attachment":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media?parent=82378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/categories?post=82378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/tags?post=82378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}