The previous two posts explored how to use the built-in sensors on the micro:bit to make and display simple measurements such a light and temperature.
This post explores how students can use code to improve their data logger. They will be able to control when to record and display the sensor reading. This makes it easier to record sensor readings in a notebook, table, or spreadsheet.
Using the code commands students will be able to press a button to record and store a measurement, another button to display the measurement, and another to reset the measurement ready to take another.
This is an opportunity (if it has not already been explored), to discuss with students how the micro:bit with only two input buttons can have three inputs. Button A and Button B and pressing them both as A and B forms a third input. Also discuss with the practicality of using the Shake command as an input in this project. Is it a good idea?
In Makecode create the following programme.
For this students will need to create a variable. This a ‘place’ where values can be stored, manipulated and recalled. Create a variable called light ( use a name that is recognisable) . In the Makecode command list, click Variables, then Make a Variable. , name the variable, this will create three new blocks.
When the micro:bit is powered up the variable is set to zero.
When button A is pressed, the sensor is read and assigned to the variable’s value. This will not change, even if the sensor reading changes unless button A is pressed again. Add a show icon block to indicate the data has been captured.
Pressing button B displays the captured sensor reading. Students can now easily record this information on a spreadsheet or table.
Pressing A+B sets the variable value back to zero ready for the next reading.
The next post shows how students can automate processes using variables and algorithms in their code.
Download this code here - https://makecode.microbit.org/_TmCH0XUsubye
Discussion
Please login to post a comment
That was fabulous - thank you!
Hi @HWaring here you go: Schools_bird_watch_complete
@pmarshman Do you a hex file for the bird count code you were showing the CAS micro:bit code-along last week (24th Jan)? I have tried to create it mysalf but my limited coding skills are sadly not up to the job!
Graham , have a look here for tips on data transfer - Datalogging with the microbit
Also, if you are not keen on soldering, search for cold solder or conductive paint , works a treat
Yes, data logging would be good. Particularly with tips on file handling and transferring data to a spreadsheet using the V2 micro:bit.
Graham
Jo,
I have a load more post to put up. What sort of things would you like to see in a plan? Stuart
Just wondered if you had formualted into a plan. No problem if not! Thanks!
Jo, Thanks… these posts are just my observations and tinkerings. What sort of planning info are you looking for?
Thanks Stuart - this looks great. Do you have planning for this as this would fit perfectly with out Year 5 classes who currently use data loggers.