Learning Functions with Microbit
Ed update: This blog was published in MicroMag Issue 6 Nov 2016. The Microbit can be used to create music. I recently watched the MicroMonsters YouTube video. The video is easy to follow and the purpose of the video is to learn to use a Piezo speaker. So of course I composed the code but I found the code very long and complex. Then I wondered how can you simplify the code to make it shorter and easier to manage. Definition Functions are a way to store information that can called at anytime during the program. Functions remove the need to type the same code over and over and allow you to reuse repetitive pieces of code. This reduces the number of lines of code and errors. Example For example, the tune of Star Wars has several parts that are repeated throughout the song. By creating a Function for each repeating part it is possible to use the function multiple times. This creates simpler code. The first phrase of Star Wars can be rewritten as SWIntro . It con...