
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#
Setup: Connect your BBC micro:bit to your PC or laptop using the Micro USB cable. Place it into the Kitronik prototyping breakout board.
Programming Environment: Open the MakeCode for micro:bit programming environment on your PC or laptop.
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
GNDor0V).Attach the resistors.
Connect the components to the Kitronik prototyping breakout board.
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.
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.
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.
Present Your Work: Prepare a short presentation to share your stoplight with the class.
Reflection: Write a brief report explaining the logic behind your code and how it results in a simulated stoplight.