<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Arduino on Decsnow Media</title><link>https://foxmedia.top/en/tags/arduino/</link><description>Recent content in Arduino on Decsnow Media</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 08 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://foxmedia.top/en/tags/arduino/index.xml" rel="self" type="application/rss+xml"/><item><title>B31DD Course Project — Traffic Light System</title><link>https://foxmedia.top/en/p/2024-12-08-b31dd/</link><pubDate>Sun, 08 Dec 2024 00:00:00 +0000</pubDate><guid>https://foxmedia.top/en/p/2024-12-08-b31dd/</guid><description>&lt;img src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/Brilliant_Curcan.png-compress" alt="Featured image of post B31DD Course Project — Traffic Light System" /&gt;&lt;h1 id="b31dd-mini-project-report"&gt;B31DD Mini-Project Report
&lt;/h1&gt;&lt;h2 id="traffic-light-display-system-with-servo-control-and-serial-monitoring"&gt;Traffic Light Display System with Servo Control and Serial Monitoring
&lt;/h2&gt;&lt;hr&gt;
&lt;h2 id="1-project-introduction"&gt;1. Project Introduction
&lt;/h2&gt;&lt;p&gt;The Traffic Light Display System is an embedded project designed to simulate a real-world traffic light controller using an AVR microcontroller. This system manages traffic flow by controlling red, yellow, and green LEDs, incorporates a servo motor to represent mechanical signaling (e.g., pedestrian crossing), displays countdown timers on an LCD, and logs traffic light changes via serial communication. Additionally, it features an interrupt-driven button allowing pedestrians to request crossing, thereby altering the normal traffic sequence.&lt;/p&gt;
&lt;h3 id="key-techniques-used"&gt;Key Techniques Used:
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Input/Output&lt;/li&gt;
&lt;li&gt;Timer&lt;/li&gt;
&lt;li&gt;Interrupt&lt;/li&gt;
&lt;li&gt;PWM and Servo Control&lt;/li&gt;
&lt;li&gt;Serial Communication&lt;/li&gt;
&lt;li&gt;LCD Display&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="2-functionalities"&gt;2. Functionalities
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Traffic Light Control&lt;/strong&gt;: Manages red, yellow, and green LEDs to simulate traffic signals.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Servo Motor Integration&lt;/strong&gt;: Adjusts the servo position based on the active traffic light (0° for red, 90° for green).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LCD Display&lt;/strong&gt;: Shows the current traffic light status and a countdown timer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serial Communication&lt;/strong&gt;: Logs traffic light changes to a serial monitor for monitoring and debugging.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interrupt-Driven Pedestrian Button&lt;/strong&gt;: Allows pedestrians to request crossing, triggering a modified traffic sequence.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="3-hardware-components-and-schematics"&gt;3. Hardware Components and Schematics
&lt;/h2&gt;&lt;h3 id="31-components-used"&gt;3.1 Components Used
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Microcontroller: AVR (e.g., ATmega328P)&lt;/li&gt;
&lt;li&gt;LEDs: Red, Yellow, Green&lt;/li&gt;
&lt;li&gt;Servo Motor: Standard hobby servo&lt;/li&gt;
&lt;li&gt;LCD Display: 16x2 character LCD&lt;/li&gt;
&lt;li&gt;Button: Momentary push-button&lt;/li&gt;
&lt;li&gt;Resistors: Current-limiting resistors for LEDs&lt;/li&gt;
&lt;li&gt;Power Supply: 5V regulated supply&lt;/li&gt;
&lt;li&gt;Miscellaneous: Breadboard, jumper wires, USB-to-Serial adapter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="Schematics" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/Brilliant_Curcan.png-compress"&gt;&lt;/p&gt;
&lt;h3 id="32-connection-overview"&gt;3.2 Connection Overview
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LEDs&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Red LED: Connected to PORTB3 through a current-limiting resistor.&lt;/li&gt;
&lt;li&gt;Yellow LED: Connected to PORTB4 through a current-limiting resistor.&lt;/li&gt;
&lt;li&gt;Green LED: Connected to PORTB5 through a current-limiting resistor.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Servo Motor&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Control Pin: Connected to PORTB2 (OC1B).&lt;/li&gt;
&lt;li&gt;Power: Connected to an external 5V supply with a common ground.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LCD Display&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Data Lines (D4-D7): Connected to PORTD4-PORTD7.&lt;/li&gt;
&lt;li&gt;Control Lines (RS, EN): Connected to PORTB0 and PORTB1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Button&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;One Terminal: Connected to PORTD3.&lt;/li&gt;
&lt;li&gt;Other Terminal: Connected to GND with an internal pull-up resistor enabled.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serial Communication&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;TX Pin (PD1): Connected to RX of USB-to-Serial adapter.&lt;/li&gt;
&lt;li&gt;Common Ground: Ensured between microcontroller and adapter.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="4-techniques-and-methodologies"&gt;4. Techniques and Methodologies
&lt;/h2&gt;&lt;h3 id="41-led-control"&gt;4.1 LED Control
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Utilized PORTB pins to control red, yellow, and green LEDs.&lt;/li&gt;
&lt;li&gt;Employed bitwise operations to set and clear specific LED states without affecting others.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="42-servo-motor-control"&gt;4.2 Servo Motor Control
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Implemented PWM (Pulse Width Modulation) using Timer1 in Fast PWM mode.&lt;/li&gt;
&lt;li&gt;Mapped specific angles (0° and 90°) to corresponding pulse widths to position the servo accurately.&lt;/li&gt;
&lt;li&gt;Configured the servo to reset to 0° during red light and move to 90° during green light.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="43-lcd-display"&gt;4.3 LCD Display
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Initialized the LCD in 4-bit mode for efficient data transmission.&lt;/li&gt;
&lt;li&gt;Displayed the current traffic light status and a countdown timer on two lines.&lt;/li&gt;
&lt;li&gt;Utilized &lt;code&gt;sprintf&lt;/code&gt; for formatting countdown strings.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="44-serial-communication"&gt;4.4 Serial Communication
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Configured USART for serial communication at 9600 baud rate.&lt;/li&gt;
&lt;li&gt;Implemented functions to initialize USART, transmit single characters, and send strings.&lt;/li&gt;
&lt;li&gt;Logged every traffic light change with appropriate messages for monitoring.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="45-interrupt-handling"&gt;4.5 Interrupt Handling
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Configured an external interrupt (INT1) on PORTD3 to detect button presses.&lt;/li&gt;
&lt;li&gt;Employed a sequence in the ISR, when the button is pressed, to display the yellow light for 3 seconds and then the green light for 5 seconds for pedestrians crossing the road.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="5-demo-results"&gt;5. Demo Results
&lt;/h2&gt;&lt;h3 id="51-normal-traffic-sequence"&gt;5.1 Normal Traffic Sequence
&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Red Light&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LED: Red LED on.&lt;/li&gt;
&lt;li&gt;Servo: Positioned at 0°.&lt;/li&gt;
&lt;li&gt;LCD: Displays &amp;ldquo;RED LIGHT&amp;rdquo; with an 8-second countdown.&lt;/li&gt;
&lt;li&gt;Serial: Logs &amp;ldquo;RED LIGHT&amp;rdquo;.&lt;br&gt;
&lt;img alt="Red Light" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/IMG_2204_Large.png-compress"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Green Light&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LED: Green LED on.&lt;/li&gt;
&lt;li&gt;Servo: Positioned at 90°.&lt;/li&gt;
&lt;li&gt;LCD: Displays &amp;ldquo;GREEN LIGHT&amp;rdquo; with a 4-second countdown.&lt;/li&gt;
&lt;li&gt;Serial: Logs &amp;ldquo;GREEN LIGHT&amp;rdquo;.&lt;br&gt;
&lt;img alt="Green Light" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/IMG_2205_Large.png-compress"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Yellow Light&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LED: Yellow LED on.&lt;/li&gt;
&lt;li&gt;LCD: Displays &amp;ldquo;YELLOW LIGHT&amp;rdquo; with a 2-second countdown.&lt;/li&gt;
&lt;li&gt;Serial: Logs &amp;ldquo;YELLOW LIGHT&amp;rdquo;.&lt;br&gt;
(Repeat cycle)&lt;br&gt;
&lt;img alt="Yellow Light" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/IMG_2206_Large.png-compress"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="52-pedestrian-request-sequence"&gt;5.2 Pedestrian Request Sequence
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Button Press Detected&lt;/strong&gt;: Triggers the ISR to execute the special sequence.&lt;br&gt;
&lt;img alt="Pedestrian" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://static.foxmedia.top/img/2024_12_01_B31DD_mini_project/IMG_2207_Large.png-compress"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Yellow Light&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LED: Yellow LED on.&lt;/li&gt;
&lt;li&gt;LCD: Displays &amp;ldquo;Pedestrians&amp;rdquo; with a 3-second countdown.&lt;/li&gt;
&lt;li&gt;Serial: Logs &amp;ldquo;YELLOW LIGHT&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Green Light&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LED: Green LED on.&lt;/li&gt;
&lt;li&gt;Servo: Positioned at 90°.&lt;/li&gt;
&lt;li&gt;LCD: Displays &amp;ldquo;GREEN LIGHT&amp;rdquo; with a 5-second countdown.&lt;/li&gt;
&lt;li&gt;Serial: Logs &amp;ldquo;GREEN LIGHT&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Return to Normal Sequence&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Servo: Resets to 0°.&lt;/li&gt;
&lt;li&gt;Resumes Normal Traffic Cycle.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="6-performance-evaluation"&gt;6. Performance Evaluation
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Timing Accuracy&lt;/strong&gt;: &lt;code&gt;_delay_ms()&lt;/code&gt; provided sufficient timing for demonstration purposes, but hardware timers are recommended for higher precision.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interrupt Responsiveness&lt;/strong&gt;: The system detected button presses and executed pedestrian requests promptly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Servo Control&lt;/strong&gt;: Smooth and accurate transitions between designated angles.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serial Logging&lt;/strong&gt;: Reliable logging of traffic light changes for monitoring.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LCD Display&lt;/strong&gt;: Consistently displayed accurate statuses and countdowns.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Areas for Improvement&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement software or hardware debouncing for the button.&lt;/li&gt;
&lt;li&gt;Extend servo angle functionality for versatile signaling.&lt;/li&gt;
&lt;li&gt;Replace &lt;code&gt;_delay_ms()&lt;/code&gt; with timer-based delays for concurrent tasks.&lt;/li&gt;
&lt;li&gt;Add error handling for USART transmission and routine interruptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="7-conclusion"&gt;7. Conclusion
&lt;/h2&gt;&lt;p&gt;The Traffic Light Display System integrates various embedded system components controlled by an AVR microcontroller. Interrupt-driven button handling adds interactivity and realism, showcasing practical applications of PWM, serial communication, and user interfaces.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="8-references"&gt;8. References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;AVR Microcontroller Datasheet&lt;/li&gt;
&lt;li&gt;Arduino Documentation&lt;/li&gt;
&lt;li&gt;LCD Display Lab3 Tutorials&lt;/li&gt;
&lt;li&gt;Servo Motor Control course material&lt;/li&gt;
&lt;li&gt;Serial Communication course material&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;</description></item></channel></rss>