Assignment 1: Interactive Traffic Light Controller

Course: DES406 Microcontrollers 1

Assessment Type: Assignment

Weighting: This assignment contributes towards the 10% allocated for Assignments/Tests.

Objective

The objective of this assignment is to develop a functional microcontroller application based on a set of requirements. You will create an interactive traffic light controller to perform a simple industrial function. This will involve designing a circuit where a microcontroller is interfaced to practical devices (LEDs and a switch) and developing the control software to meet the given specifications.

Learning Outcomes Assessed

This assignment provides an opportunity to demonstrate competency in the following course learning outcomes:


Part 1: Hardware Implementation and Circuit Assembly

Learning Outcome Met: LO1 - Demonstrate and apply knowledge of microcontroller hardware.

Justification: This section requires you to build a functional circuit. A microcontroller is interfaced to practical devices (LEDs, a push button, and resistors) by connecting them to the correct I/O pins. The microcontroller on-board subsystems (digital I/O ports) must be correctly wired to external components, demonstrating an applied understanding of hardware interfacing in accordance with standard industry practice.

Task Specification

Using the Tinkercad simulation environment, you are required to assemble the following circuit:

Required Components

Assembly Instructions

  1. Place the three LEDs on the breadboard, connecting each anode (long leg) to a separate digital pin on the Arduino via a 220Ω current-limiting resistor. Connect all cathodes (short legs) to the common ground (GND).
  2. Place the push button on the breadboard. Connect one terminal to a digital input pin on the Arduino. Connect the same terminal to GND via a 220Ω pull-down resistor. Connect the opposite terminal to the 5V supply.
Note on Industry Practice: The use of current-limiting resistors for LEDs and a pull-down resistor for the input button are standard design considerations to protect the microcontroller's I/O pins and ensure stable, predictable input signals.

Part 2: Software Development and System Logic

Learning Outcome Met: LO2 - Demonstrate practical microcontroller software development methods.

Justification: This section requires you to write and test embedded software. An IDE is used to demonstrate practical software development methods for microcontrollers. Programs for a microcontroller are written and documented based on given specifications to solve a defined problem. This includes using control structures, functions, and debugging outputs, all of which reflect standard industry practice for software development.

Task Specification

You will write C++ code for the Arduino to control the traffic light system. The program must be developed in two stages.

Stage A: Basic Automated Cycle

First, implement a non-interactive traffic light sequence that repeats indefinitely. The on-board subsystems (timers and digital I/O) must be configured to achieve the following sequence:

  1. Green light ON for 5 seconds.
  2. Yellow light ON for 2 seconds.
  3. Red light ON for 5 seconds.
  4. The cycle repeats from step 1.

Stage B: Interactive Pedestrian Crossing

Modify your program to incorporate the pedestrian push button. The system must poll this input to alter its behaviour as specified below:

  1. The system runs the normal cycle from Stage A.
  2. If the push button is pressed while the light is Green, the system must detect this input and interrupt the normal green light timing.
  3. The sequence must then proceed immediately to Yellow (2 seconds), followed by Red.
  4. The Red light must remain on for an extended duration of 7 seconds to allow for pedestrian crossing.
  5. After the extended Red light duration, the system must return to the normal cycle (starting with Green).
  6. Button presses that occur during the Yellow or Red phases must be ignored.

Implementation Requirements & Industry Practice

To demonstrate professional coding standards, your programs for the microcontroller must be written and documented adhering to the following guidelines:

Submission

  1. A public share link to your completed Tinkercad project. The project must include both the correctly assembled circuit and the final, commented code.
  2. A copy of your Arduino C++ code submitted as a separate .ino file.

Grading Rubric

Criteria Points Learning Outcome
Circuit correctly interfaces practical devices in Tinkercad. 15 LO1
Stage A: Basic automated traffic light cycle is correctly implemented. 20 LO2
Stage B: Pedestrian button logic is correctly implemented as per specifications. 30 LO2
Code uses constants, an array, and custom functions as required. 15 LO2
Serial Monitor output is used effectively for status and verification. 10 LO2
Code is well-structured, readable, and documented in accordance with industry practice. 10 LO2
Total 100