You get a bonus - 1 coin for daily activity. Now you have 1 coin

Online simulation of the atmega328p three-led traffic light circuit circuit

Classic traffic light on ATmega328P: red (D2), yellow (D3) and green (D4) LEDs cycle with delay() timing — red, red+yellow, green, yellow.

This page is a utility for simulating atmega328p three-led traffic light circuit online with specified initial values.

The online circuit simulator allows you to model circuit behavior in real time. You can change circuit parameters, add new elements, and observe their interactions. This is a useful tool for learning and experimenting with electronic circuits.
⚡ Circuit Online 
Left-click — place/select · hover over an end (◯ highlights) and drag — stretch · wheel — zoom · middle-click — pan · double-click — settings

The ATmega328P microcontroller implements a classic three-section traffic light using three LEDs: the red one is connected to digital pin D2, the yellow one to D3, and the green one to D4. Each LED is connected through a current-limiting resistor, ensuring a safe operating current and protecting both the LEDs and the microcontroller pins.

After running the program in the setup() function, pins D2, D3, and D4 are configured as digital outputs. The main operating logic is implemented in the loop() function, which continuously cycles through a sequence of traffic light states, simulating the operation of a real road object.

The operating cycle consists of four main stages. First, the red signal turns on, prohibiting movement. Then, the red and yellow LEDs turn on simultaneously, signaling preparation for movement. After this, the green signal turns on, permitting movement. Finally, the yellow signal turns on, warning of an imminent switch to prohibiting mode. After this stage, the program returns to the initial state, and the cycle repeats indefinitely.

The time intervals between switching events are implemented using the delay() function, which pauses program execution for a specified number of milliseconds. By changing the delay values, you can adjust the duration of each signal and simulate different traffic light operating modes.

The program source code can be edited directly in the microcontroller properties in the simulation environment. After making changes, the updated sketch is automatically uploaded to the ATmega328P model, allowing you to quickly modify the traffic light algorithm, experiment with signal durations, and explore the principles of controlling the microcontroller's digital outputs.


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply