When determining if an area is suitable for human purposes, e.g, Farming, settlements. One may place a device in the area that will record the conditions in the area. This lesson will both show how to record measurements over a period of time, and how to view live readouts from our microbits.
To record lots of values, we need to make a list (or Array). A list is like a name for a bunch of stored variables. Each value (or element) in the list can be accessed later for whatever we need. To create a list in MakeCode, we go into Advanced -> Arrays and drag out a “[List] add value ___ to end” block. Place that into the forever loop.
Rename the list to “Light Levels”, as this List is going to store all the light levels that a region has throughout the day. Then go to Input and drag out the “Light Level” block and place that within your “[Light Levels] add value ___ to end” block. We will also need a pause block, to prevent our micro:bit from immediately filling up the micro:bit's memory in a short time. Set this pause block to wait for around 10 seconds (10,000 ms).
Now, we will need to view all of these values at some stage. To do this, we will drag out from Input - On button [A] pressed. Then drag out of Loops - “For element (value) of [List]” block, and place it inside, change the “list” part of the block to your “Light Levels” list. This “For element (value) of [List]” block will loop through all the saved list elements.
Inside the loop, we will like to display the saved values, and show a comma [ , ] between each one. Go to Basic and drag out 2 show string blocks and place them within the loop. Then drag the (value) block from the loop, and place it within the first show string block.
You can repeat this process for as many lists as you like, so you may want to store the temperature in a region. Or you may want to measure the acceleration of your micro:bit over time.
Before this, make sure your micro:bit is paired with your iPad.