This project is used to build basic concept of list, get familiar of basic operations of list, and use for-looping to access the stored elements values. This is a knowledge base for further projects using lists and looping. Goals:
Basic operation of lists, add and remove element
Use count-controlled for-looping to access list elements
A basic debugging experience to watch the lists changes and looping
START A BIT > Projects Library > This page
Here is the demo of the basic requirement, and a short introduction of how to debug.
This project uses 1 Micro:bit board with a USB cable, nothing else needed.
The basic part of the program is ready-made and provided to the student to directly inspect and debug
A list created on-start, with default 3 number-elements
Press button-A to add a random number (within 0-9) to the end of the list, show this number on LED screen
Press button-B to pop-up the last number from the list
Press LOGO to read and show the stored numbers
Task 1: When pressing A+B, find the max value from the list, then show it
Task 2: Improved logic for button A: Check values duplication, warn a sound, don't add duplicated new values
[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 minutes: Understand requirement and solution, collect materials
15-20 minutes: Use debugger to inspect how the things happen and the changes of list length, index, values
10-15 minutes: Task 1, find the max num
10-15 minutes: Task 2: check duplication
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
1x Micro:bit V2 board , with USB cable
List v.s. Array
Index
Elements/Objects/Values
Copy the code as the picture, or directly get a copy from MakeCode shared project: PJ017: Debug The List Changes And Find The Max - Demo Debug Only.
Please read and understand the logic, then download to Micro:bit to test.
Follow the tutor to learn how to start debug, and watch the changes of list.
Then, please repeat and explore the debugging by yourself.
When pressing button A+B
Find the max value from the list
Show this number on LED screen
The purpose of this task is to practice using for-looping to access elements in the list.
There are many ways to do so, one of the solutions:
Create a variable "max_value"
Let "max_value" be any value from the list
Go through all the values from the list, compare with max_value, update it to be the value that is bigger than it was
Here is a working copy, if you need...
When pressing button A
Check if the new random number already exists in the list
If yes, then warn a sound, and don't add it into the list
The purpose of this task is to practice using for-looping to access elements in the list.
There are many ways to do so, one of the solutions:
Go through all the values from the list using for-looping, compare with the new generate number, if yes, then a duplication is found
Use "break" to jump out of the looping when it's found already
No lazy working copy here, please solve it.
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
Find out working copy as a MakeCode shared project.