The project is a black box with two switches and a potentiometer used in order to create music. The upper switch, mapped to A1 on the Playground Express board, is used to turn device on or off. Off is the default. The central switch, mapped to A2, is used to switch between having the potentiometer control setting the music's volume and playing a melody. The default is controlling the volume. When the potentiometer is controlling playing a melody, the melody played is randomized with constraints based on the value the potentiometer is set to.
The randomized melody is made as follows. In a for loop going from 0 to 8, the device chooses a set of keys randomly based off of the potentiometer value and stores the key in a list. If the potentiometer is in its first tenth, it chooses from C, D, and E. If it is in its second tenth, it chooses from D, E, and F. If it is in its fifth tenth, it chooses from A, B, and C5. Et cetera. Once it has eight keys selected it converts the list into a string for the play melody block to read in and play at 256 bpm.1
Published September 24, 2021
Comments
Please log in or sign up to comment.