Skip to content

mogeadis/AVRaffic-Light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AVRaffic Light 🚦

Table of Contents

Description

Project

AVRaffic Light demonstrates the operation of a traffic light circuit controlled by an ATmega328P microcontroller, with user input provided via a push-button and a potentiometer to drive a series of light-emitting diodes (LEDs). The firmware is written in bare-metal C, with the purpose of understanding embedded systems and hardware-level programming beyond the abstractions of the commonly used Arduino interface. Specifically, the development of this project covers the exploration of these fundamental concepts:

  • Analog-to-Digital Converters (ADCs)
  • Callbacks
  • Finite State Machines (FSMs)
  • General Purpose Input/Output (GPIO)
  • Hardware Abstraction Layer (HAL)
  • Interrupt Requests (IRQs)
  • Interrupt Service Routines (ISRs)
  • Polling
  • Pulse Width Modulation (PWM)
  • Software Debouncing
  • Timers
  • Universal Asynchronous Receiver/Transmitter (UART)

You can interact directly with this prototype traffic light circuit on the dedicated Wokwi simulator project page.

Repository

The code in this repository is organized into two directories, namely include and src, which contain the header (.h) and source (.c) files of the project, respectively.

Technical Details

This project was developed using Visual Studio Code on Windows 10, with the PlatformIO extension employed to upload the code to the ATmega328P microcontroller embedded in an Arduino Nano board. The prototype circuit additionally consists of a common cathode 7-segment LED display, and three individual LEDs corresponding to the familiar traffic light colors. Resistors with an arbitrary value of 1KΩ are connected to each LED to prevent excessive current. Lastly, a push-button lights up the decimal point of the 7-segment display when pressed and is used to immediately advance from the red to the orange state of the traffic light, while a potentiometer controls the brightness of all LEDs via PWM. Note that, at the moment of compiling this documentation, Wokwi does not seem to support dimming of a 7-segment display by driving the common pin with a PWM output, however prototyping on physical hardware has validated the intended functionality of the circuit.

Circuit Diagram

circuit.png

Acknowledgements

This project was inspired by the Bare-Metal C programming series by Cosmic Aerospace Technologies. Completing this series was an instrumental step in gaining a solid understanding of bare-metal programming of AVR microcontrollers, laying the groundwork to build on the introduced fundamental concepts to develop a more complex and self-contained educational project.

License

AVRaffic Light © 2026 by Alexandros Iliadis is licensed under the MIT License.

A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

See the LICENSE.md file for more details.

About

AVRaffic Light is a prototype traffic light circuit based on the ATmega328P microcontroller of the AVR family, programmed in bare-metal C. This project was developed in 2026 as part of a personal endeavor to learn more about embedded systems and bare-metal microcontroller programming.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages