SparkFun gator:bit v2 Hookup Guide

Pages
Contributors: LightningHawk, Englandsaurus
Favorited Favorite 1

Example Project: Button Melody Player

This project makes use of the speaker and buttons A and B. This project is easily extendable by using alligator clips on pins 5 (button A) and 11 (button B) to trigger the button-press event using external hardware like buttons or reed switches.

Example

Re-create the following code into your MakeCode editor or download the example by clicking the download button to test it out!


At the start of the program an eighth note is displayed on the micro:bit's 5x5 LED matrix. When button A or B is pressed a video game type melody is played. You can choose from several melodies or make one of your own. By adding a few more buttons and using the "on pin __ pressed" code block on pins 0, 1, or 2, you could create a 5 button drum machine or synthesizer!

Example of "is pressed" block

This function can be found in the "input" extension in makecode.