This project bases on PJ003: External LED + button with Micro:bit for hardware setup, uses Micro:bit pin 0 with external button as digital input, and pin 1 with external LED as digital output, then uses built-in button A + B + external button together to light up external LED, programmed by MakeCode blocks. This is an example of software enabled "hidden features" of a product. Goals:
Consolidate understanding of digital signals as input and output
LED as the typical simple digital output-er, button as the typical simple digital input-er
Read digital signal from Micro:bit pin as input
Write digital signal to Micro:bit pin as output
Hardware: LED, Tactile button, and wiring
Software: Compound conditions for if-else
Inspire software defined features
Testing thinking for complex software logic
START A BIT > Projects Library > This page
Here is an example of the successful result done by our student.
The hardware setup is basically the same as PJ003: External LED + button with Micro:bit.
Use Micro:bit pin 0 as digital signal input from external button
Use Micro:bit pin 1 as digital signal output to drive external LED
Use Micro:bit built-in A/B as digital signal input
Initially, the external LED is off
When pressing 3 buttons all together(external button + builtin button A + builtin button B) to light up the external LED
Otherwise, in any other condition, the external LED is kept off
[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
20-25 minutes: Hardware setup and wiring
20-25 minutes: Programming
5-10 minutes: Download and test, correct and re-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
LED basic what/how: Should be able to identify and connect the legs correctly
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
Better to have successfully completed
1x Micro:bit V2 board , with USB cable
1x breadboard
1x LED, random color
1x 220 Ω resistor
1x 10 kΩ resistor
Some jumping wires
The hardware setup is exactly the same as PJ003.
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.
LED's 2 pins are polarized! Recognized the difference, wire the "-" leg towards GND. ("big foot on ground")
Learn more: LED basic what/how.
Place the button in the middle of the breadboard, pay special attention to the 4 pins orders!
Usually, by this tip so far and active exploration, you can get it done!
…Please try really hard, before getting super tips if you are stuck.
To get built-in button A+B pressed as a logical condition, use "Input -> button... is pressed"
To get external button digital signal input, use "Advanced -> Pins -> digital read pin..."
To link the logic, you need a if-else block and logic judgement blocks, use "Logic -> Conditionals -> if... then..." and "Logic -> Comparison -> ... = ...", and "Logic -> Boolean-> ... and ..."
To drive digital signal output so to turn on/off the external LED, use "Advanced -> Pins -> digital write pin..."
You also need "on start" and "forever" block to help making things work.
These are all the needed types of blocks, be aware that some blocks might be needed for multiple times, duplicate them if needed. Usually, by this tip so far and active exploration, you can get it done!
…Please try really hard, before getting super tips if you are stuck.
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
This project uses complex combined buttons to trigger an interesting secret feature, meanwhile it easily introduce bugs. Please think and discuss about
How much confidence about correct result do you have when completing the programming
How much confidence do you believe what your group members have done?
Which test cases must you do for this project before declaring a success?
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
Draw the flow chart of the program, this project is good for this practice.