Crosswalk Diagram

  1. Build a simulation of a single traffic light with a cross-walk button (red, yellow, green for the traffic light, and perhaps white, red for the cross walk signal). There should be one button that, in its turn, allows pedestrians to cross the street. Steps to complete:
    1. Create a Finite State Machine (FSM) diagram for the traffic light alone.
      1. Identify the possible STATES of your system.
      2. Identify which TRANSITIONS between STATES are possible.
      3. Identify the CONDITIONS under which the TRANSITIONS between STATES are allowed to occur.
      4. Draw diagram of the FSM
    2. Build the circuit, write some code and test it.
    3. Augment your FSM diagram to include the cross-walk behavior.
    4. Build the circuit, write some code and test it.
  2. Key questions you are expected to be able to answer after the Traffic Light project above.
    • Variables
      • What is a variable and how do you declare them in C++?
      • What is a variable’s scope and what is the difference between a global scope and a local scope?
      • Why might you declare a variable as read-only using the const keyword?
      • What are the differences between long, int, float and bool and when would you choose one over another?
    • Functions
      • What are functions and how do you declare them in C++?
      • Why would you use a function?
      • What does void mean in the context of a function declaration?
      • How is the return keyword used and in general what does it mean to return from a function?
    • Program Flow
      • What does Arduino’s setup() function do?
      • What does Arduino’s loop() function do?
      • Why might it be important to avoid the delay() function?
    • Control
      • What is an if / else statement?
      • What is an if / else if / else statement?
    • Timing
      • What is the millis() function and how does it work?
      • What is the micros() function and how does it work?
    • Finite State Machine
      • When might it be useful to use a finite state machine (FSM)?
      • What are states and how do they relate to outputs?
      • What are events (aka state transitions) and how do they relate to inputs?
    • Input / Output
      • What are the steps for declaring and initializing an input pin?
      • What are the steps for declaring and initializing an output pin?
      • What are the purposes of digitalRead(), digitalWrite(), and pinMode()?
    • If you are unsure of the answers any of those questions, look it up or check your notes. If you are still are unclear post a question to the forum and we’ll discuss it.