Interactive Traffic Light Programming Challenges
Explore Bronze, Silver, Gold, and Extension challenges to create a traffic light program using NeoPixels. Start with setting up traffic light sequences, adding animations for pedestrian safety, incorporating variable colors, and enhancing code structure with functions and loops. Take on the Extension Challenge to improve code organization further.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
Traffic Lights This week you be creating your own traffic light program using NeoPixels. Whether programming in blocks, JavaScript or Python, please complete the bronze requirements before starting the silver, and complete the silver before starting the gold.
BRONZE Challenge: 1. Create a start-up for your traffic light program 2. Use the blocks provided by the Neopixel extension to connect a 24 LED strip to pin 1 3. Set up 3 equal size ranges to recreate a traffic light with red at the top, yellow in the middle, and green at the bottom 4. Have the traffic light repeatedly cycle through a crossing sequence - that is red for 10 seconds, red and yellow for 5 seconds, green for 10 seconds, and then yellow for 5 seconds.
SILVER Challenge: 1. Move each light change into their own functions, remember to then call them in the forever loop. 2. Add animations to the Micro:Bit to show when it is and isn't safe for pedestrians to cross the road. Do this using three new functions - one for walk, one for wait, and one for warning that the lights are changing to green for the traffic.
GOLD Challenge: 1. Create a traffic light colour variable for use to identify which light is currently active and use this in if/else if statements for setting the lights 2. Have the A button on the Micro:Bit cause the traffic to come to a stop (safely). Important: You can stop a loop early using the 'break' block found in the Loops menu. 3. Add sound to indicate when it is safe to cross for those who cannot see the visual instructions.
Extension Challenge: Add a second NeoPixel as the traffic light for the other direction. How much can you tidy up your code with functions, while loops, repeat blocks and variables?