Lab: Simulating a Stoplight

header-lesson-03

Lab: Simulating a Stoplight#

Objective#

In this lab, you will simulate a stoplight using the BBC micro:bit.

Materials#

  • 1 PC or Laptop

  • 1 BBC micro:bit

  • 1 Micro USB cable

  • 1 green LED

  • 1 yellow LED

  • 1 red LED

  • 3 47Ω resistors (yellow, violet, black, golden)

  • 4 male-to-female jumper wires (can match the colors of the LEDs, and GND)

  • 1 Kitronik prototyping plate (micro:bit breakout board and breadboard)

Instructions#

  1. Setup: Connect your BBC micro:bit to your PC or laptop using the Micro USB cable. Place it into the Kitronik prototyping breakout board.

  2. Programming Environment: Open the MakeCode for micro:bit programming environment on your PC or laptop.

  3. Build Your Circuit:

    • Place the red, yellow, and green LEDs in the breadboard.

    • Add the resistors to the proper leads. (Remember that the shorter lead is attached to GND or 0V).

    • Attach the resistors.

    • Connect the components to the Kitronik prototyping breakout board.

  4. Code Your device: Using the MakeCode editor, write code to control your device.

    • Think of a stoplight:

      • What is the sequence of the different lights?

      • What are possible durations for the lights?

      • Can you use a button to trigger the stoplight? (Not required)

    • Write code to reflect the values.

  5. Test Your Device: After you’ve written your code, download it to your micro:bit and test your device. Make sure all lights behave like a stoplight.

  6. Document Your Work: Take pictures or videos of your simulated stoplight in action. Write a brief report explaining your design process, how you coded your device, any challenges you faced, and how you overcame them.

  7. Present Your Work: Prepare a short presentation to share your stoplight with the class.

  8. Reflection: Write a brief report explaining the logic behind your code and how it results in a simulated stoplight.