This project uses Micro:bit pin 0 with external button to trigger a happy face on built-in LED matrix, programmed by MakeCode blocks. Goals:
Digital signals and input/output basic understanding
Button as the typical simple digital input-er
Read digital signal from Micro:bit pin as input
Hardware: Tactile button and wiring
Software: if-else logic condition, comparison judgement
START A BIT > Projects Library > This page
Here is an example of the successful result done by our student.
Use Micro:bit pin 0 as digital signal input from external button
Use Micro:bit built-in LED matrix to visualize the button status
Initially, the built-in LED matrix should show a dull face or sad face
If pressing external button, show a happy face on the built-in LED matrix
If releasing external button, the built-in LED matrix should show the initial face
[x] Simple: 30-60 minutes
[ ] 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-10 minutes: Understand requirement and solution, collect materials
15-20 minutes: Hardware setup and wiring
10-15 minutes: Programming
1 minutes: Download and test
One should have prior knowledge
Micro:bit V2 board, Micro:bit pin breakout board, Breadboard: Know what they are, better to have prior experience using them
MakeCode by Microsoft, the programming tool, better to have prior experience using it with Micro:bit
Tactile switch/button basic what/how : Should be able to identify and connect the legs correctly
Resistor basic what/how: Just need to know what it is, better to know why we need it here, no need to know how to read the color rings
1x Micro:bit V2 board , with USB cable
1x breadboard
1x 10 kΩ resistor
Some jumping wires
This is what you need to build in a simplified 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.
To get input of digital signal from a specific pin
Advanced -> Pins ->
To link the logic, you need a if-else block and logic judgement block as well
Logic -> Conditions ->
Logic -> Comparison->
To show a happy face on Micro:bit built-in LED matrix
Basic ->
You also need "on start" and "forever" block to help making things work.
Tip: If you don't know what to do with the "if-else" and "0=0" blocks...This is the final look after putting those logical blocks together
This optional part covers further competence development, in terms of testing, troubleshooting, analysis, documentation, flow chart diagrams practices, etc.
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
Use your own way to visualize how the hardware components are connected by a free style drawing.
Visualize clearly the wiring path, mark clearly the pins and end points
So that your friends can follow this drawing to correctly reproduce the hardware setup
Any kind of children style drawing is OK! Here are some examples.
Use your own way to visualize how the programming controlling logic is done, by a free style drawing, so that your friends can follow this flow-chart to reproduce the programming.
You might be interested to know what is "flow chart", click to learn more, but so far, it's not needed to be that serious, just draw something that can help you explain to your friends how the programming is made.
What is the possible value of a digital signal?
When pressing the button, what is input to the Micro:bit?
These questions are out of scope for this project, but great to think about them, ask and discuss if you have enough effort
Why do we need a resistor with the button? What if we remove the resistor?
How to read the resistor value by the color rings?
If you get a quick done, do you dare to take further challenges? Those challenging points are independent, not related to one another
Change button connection from pin 0 to pin 1, implement the same requirement
What if you remove the resister that is called "pulling down resister"? Actually, there is a software solution for this, use the block "Advanced -> More -> set pull pin .. to ...", can you try it out?
Try next project PJ003: External LED + button with Micro:bit
Find out a working copy as a MakeCode shared project
Used in Session w17 of LP2415: 4 Weeks Refreshing Package, 24w15
Used in Session w46 of LP2346: 3 Weeks Recap & Review, 23w46