This project uses Micro:bit built-in button A/B to control external LED connected to pin 1, programmed by MakeCode blocks. The basic requirement is to on/off the LED, then there are several challenges for those who want to try further. Goals:
Digital signals and input/output basic understanding
LED as the typical simple digital output-er
Use digital signal from Micro:bit built-in button as input
Write digital signal to Micro:bit pin as output
Hardware: LED basic, pins and wiring
Software: if-else logic implicitly used
Homework Challenges:
Blink the external LED
Change the blinking speed with built-in button A/B. This involves variable exercise.
START A BIT > Projects Library > This page
Here is an example of the successful result done by our student.
Use Micro:bit built-in button A & B as digital signal input from user
Use Micro:bit pin 1 as digital signal output to drive external LED
Press built-in button A to light up the external LED, and
Press built-in button B to turn off the external LED
[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
10-15 minutes: Hardware setup and wiring
10-15 minutes: Programming, testing
10 minutes: Optional, measure the voltage of pin
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
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 LED, random color
1x 220 Ω 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.
LED's 2 lead are polarized! Recognized the difference, wire the "-" leg towards GND.
Learn more: LED basic what/how.
This is an event triggered block, available to capture button events A/B/A+B
Input ->
To output a digital signal to a specific pin
Advanced -> Pins ->
This snippet is for button A, to trigger digital signal output as HIGH.
By this,
This is an optional task to measure the PIN 1 voltage level, so to enhance the understanding of voltage as signaling, and the digital signal output as voltage, and a special attention to digital signal as floating output.
Disconnect the PIN1 wiring, so it's not connected to anything
Use the same program, measure the PIN 1 voltage, observe and write down the value for
Nothing pressing at the initial state
button A pressing
button B pressing
Take the test multiple times, think and analyze
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.
Tell us what is digital signal in your own way, explain how the digital signal as output happens in this project.
Can we connect LED to pin 0?
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 LED? What if we remove the resistor?
How to read the resistor value by the color rings?
So now, it should be not hard to try blinking the LED
So now, it should be not hard to try blinking the LED
Requirement:
Requirement:
If you get a quick done, do you dare to take further challenges? Those challenging points are independent, not related to one another
Change LED connection from pin 1 to pin 0, implement the same requirement
Implement the same requirement, but don't use "Input -> on button … pressed" block to get button input
Try next project PJ003: External LED + button with Micro:bit, variable usage
Try PJ006: Same 1 button to on/off external LED with Micro:bit with variable and boolean type logic
Find out a working copy as a MakeCode shared project
Used in Session w16 of LP2415: 4 Weeks Refreshing Package, 24w15
Used in Session w46 of LP2346: 3 Weeks Recap & Review, 23w46