Our code worked by using the “System Execution” command which can control the terminal of the computer. We typed the command “afplay” then the path to a particular sound file we had saved on the computer. There was a sound file for each note of the scale, the 5 sound effects, and the 2 drum sounds. For the piano and drums we also added “-t 0.1” which played the sound file for only 0.1 seconds since the notes had to be quicker than the sound effects so consecutive notes could easily be played. For the piano, “System Execution” and the corresponding terminal command to play a specific sound file were placed inside of the true part of a case structure, causing a sound to play when a touch sensor (pressed) returned true. For the sound effects, the “System Execution” and the corresponding terminal command to play a specific file were also inside the true part of a case structure. The motor would first reset rotation to 0, then a read rotation was called. If the motor read an angle of rotation value that did not equal 0, then true was returned to the case structure, causing the sound to be played. The 3 EV3s, which we previously had daisy-chained, were each attached to their own USB ports in order to decrease delay. We had multiple EV3s in our program using the “Specify NXT/EV3” command, wiring the names of each EV3 into their respective blocks, then wiring those blocks to the sensor each EV3 controlled. 2 of the EV3s and the code for the piano and sound effects were attached/played from one computer, then another computer was used to attach/play the drums from the third EV3. The whole program was inside an infinite while loop (false wired into stop).
One challenge we faced was finding a way to attach all 3 EV3 to its own port to reduce delay since one computer only has 2 USB ports and the code did not respond well with a USB expander. We solved this problem by running the drum program on a separate computer and attaching the third EV3 to the second computer as well.
We made several improvements to our original prototype design to improve the Composer music box. One improvement we made was making the box more aesthetically pleasing. We did this by using a different box, wrapping it with wrapping paper, and placing the three components of our box in more sensible and symmetrical places, and containing the EV3s and wires inside the box so they could not be seen from the outside. We also made the design more intuitive by moving three of the sound effects to the front of the box (which was especially more accessible for children), and adding more, colorful pictures and note names to each of the components so it was easier to understand which control did what. We also greatly improved the drums. Before, the drums were ultrasonic sensors which were inconsistent and difficult for the younger children to understand and use. Instead, we decided to use a touch sensor attached to a cardboard disk with an axel which greatly increased consistency and usability. We also drew a drum on the cardboard disk so the children would understand that it was a drum. We also made an improvement that greatly reduced the delay of the controls and also allowed multiple people to easily play at the same time. We reduced delay by, instead of daisy-chaining 3 EV3s (which took a long time for all of them to communicate), attaching each EV3 to its own USB port. Lastly, we added two more sound effects (duck and horse) as well as sheet music so people could play songs to add even more to the fun.