Assignment 4
- ncampanelli0
- Sep 24, 2019
- 1 min read
Using object oriented programming in python, I made a simple music player. The bpm is controlled by the knob and is determined by the knob's value + a baseline value. In the code itself the baseline can be manipulated when calling the function, if not it is initialized at 80. The a button is to change what plays, making use of an array to store all the "tune" variables (as of right now that is the opening of tetris and 3 beeps) and keeping track of an integer variable to use as the argument for calling the array. The b button acts as a play/stop button. One thing I learned was that you can define a boolean and set it not equal to itself (boolean != boolean), I can already see this trick being useful in future programs I write, it is much less cumbersome then using if/else statements to manipulate an integer between 0 and 1.
link to code: https://repl.it/@ncampanelli0/microbit-simple-music-player
Commenti