86

Programming Training Hub

Training Sections

Challenges

These are meant to test your understanding of each section in a unique way - try to complete everything here. Working on a project can help you learn a lot faster than just reading!

Project 1: Command-Based Lights (sections 1 to 3.1)

Project details:

  • Your goal is to create a traffic-light system in robot code!
  • The lights will be DigitalOutputs, each representing a different color (red, yellow, green).
  • You should have a LightSubsystem (or similarly named subsystem) and should use command compositions when commands are too short to get a dedicated file.
  • You should have sequences to automate a sequence of lights (for example, green for 10s, yellow for 3s, red for 16s)
  • You should also add the ability to manually set the lights - make sure that you can't confuse our imaginary drivers by having two lights on at once!
  • Should be controllable using either an xbox controller or a generic joystick, depending on what is available to you
  • Keep your code readable, well-documented, and have ample logging

Extra challenge:

  • Add another layer of complexity by having car sensors!
  • Create a second subsystem with DigitalInputs that can detect the weight of cars waiting at the lights.
  • You should also try to include some way to check how long its been since a car last went over the sensor - are there no cars coming?
  • Do whatever with this extra input! For example, you can make it so that if a car is waiting at a red light and no cars have passed through the opposing green light in a while, it advances faster to get the waiting cars moving earlier.