This project makes more fun by using the knowledge of digital signal output, it's based on PJ001: External LED with Micro:bit. The program is made by MakeCode, the codes logic is simple, the implementation can be rather straightforward in a kids way, or can be guided to improve for very well structured logic using Variables/Functions. Goals:
Fun experience with Micro:bit's digital outputs, also as preparations for further creative projects
Experience with simple programming, inspire to start using Functions (Not a must, but motivate a feeling of the needs)
Enhance the understanding of digital signals, outputting digital signal with Micro:bit
START A BIT > Projects Library > This page
Here is an example of the result done by our student.
Wire the external LEDs using PIN 1, 2, 8. Some other PINs are also available, but not all are working due to duplex of other software functions, so please use PIN 1, 2, 8 as a starting here.
Program to make a fixed schedule of looping RED to GREEN and back to RED:
RED (10s)
-> YELLOW(3s) -> GREEN(10s)
-> YELLOW(3s) -> RED (10s)
-> YELLOW(3s) -> GREEN(10s)
…
[ ] Simple: 30-60 minutes
[x] Moderate: 1-2 hours
[ ] Challenging: more than 2 hours
The estimation bases on average situation without unexpected troubleshooting, assuming that the student meets prerequisites. It only indicates rough time needed to complete this project, but not about technical difficulty, not covering discussion and sharing time. Here is a possible breakdown:
5 minutes: Understand requirement and solution, collect materials
15-20 minutes: Hardware wiring
15-30 minutes: Programming, download and test
15-30 minutes: Optional, optimize the codes using Functions
One should have prior knowledge
Micro:bit V2 board: Know what they are, better to have prior experience with it
MakeCode by Microsoft, the programming tool, better to have prior experience using it with Micro:bit
Better to have done PJ001: External LED with Micro:bit
Function knowledge is not a must, but good to have prior ideas of what it is
1x Micro:bit V2 board , with USB cable
1x Green LED
1x Yellow LED
1x Red LED
3x resistors
A few jumping wires
This is what you need to build in a simplified graphical view.
Use the micro:bit pin breakout and breadboard to connect the components, you don’t need to use the exact holes in the breadboard as others, as long as the wiring path is correct.
NOTE:
The shcema picture's pin orders in the pin breakout is different from what we actually have, please find the correct pin to wire.
LED's 2 leads are polarized! Recognized the difference, wire the "-" leg towards GND.
Learn more: LED basic what/how.
To output a digital signal to a specific pin
Advanced -> Pins ->
Not a must, but it's highly recommened to consider using Functions! You can do so as an optimization after creating a working prototype.
Advanced -> Functions
This snippet embedded in a function shows the full feature to turn on the red LED, play a warning sound, after a while and turn off it.
By this tip, you can figure out the "yellow_on_then_off", "green_on_then_off", then you are ready with all the important parts!
Stand in front of the class, share with your group what you have made, please cover important points
Tell what it is your product
Demonstrate how it works
Explain how it works
Share with your group about
What troubles you met
How you analyze
How you get help
How you solve it
What you have learnt
When you have got a working version, please consider
What could be the problem with the straightforward coding flow without functions?
What can we do to simplify/optimize it as a pro?
If you get a quick done, do you dare to take further challenges? Those challenging points are independent, not related to one another
Please consider optimize your program using Variables/Functions, you will be like a PRO with those!
Find out working copies as a MakeCode shared projects, these 2 examples shows the difference before and after optimization using Functions.
Used as homework in LP2415: 4 Weeks Refreshing Package, 24w15