Development (Electronics)

Page

Our musical box has 2 main modes – a music mode as well as a score system. We grouped each face of the box into 3 concentric circles with different variations for each mode.

Concentric circles on one face of box

For the music mode, the outer two concentric circles would produce a different musical note, with the innermost circle producing a song. Hence, a total of two notes could be produced on each side.

To add an even deeper layer of complexity, we implemented a score system as well. Hence, an additional objective of the game was to score as many points as possible within two minutes. Each concentric circle was associated with a different number of points, with the innermost circle having 3 points, the second circle having 2 points and the outermost circle having 1 point.

We also added an LCD screen to display real-time information such as the score and the note produced. Other information such as the time left was displayed on the serial monitor due to the limited display of the LCD screen.

The dual modes of the game were able to cater to an auditory audience with the notes produced, as well as motivate users with the points system. The development of our electronics to achieve these 2 modes will be discussed below.

Week 1-3

Component: Circuitry (proof of concept)

Idea: As a proof of concept, we initially wanted to follow the example of an Arduino piezo piano to connect our circuits, as shown in the diagram below. This example connects 5 piezo sensors using a breadboard and each piezo sensor functions as a piano key, which is highly similar to what we want to achieve with our box.

Arduino Piezo Piano Circuit Diagram Credits: https://www.instructables.com/id/Arduino-Piano-With-Piezoelectric-Sensors/

Did it work out? Seeing that our initial proof of concept worked out, we realised that it would be feasible to use piezo sensors to achieve our outcomes. However, due to the large scale of our project, we found that it would be too messy to merely rely on a breadboard and the chances of loose connections were high. Furthermore, even with an Arduino Mega, we would not have enough analog pins to accommodate 125 piezo sensors.

In the end ... we had to explore other alternatives to overcome these, such as with the use of multiplexing and PCB.

Weeks 6-7

Component: PCB

Idea: We decided to use multiplexing to reduce the number of pins required. As such, for each side of the box, the keys are grouped into 3 groups based on each concentric circle. This would reduce 125 analog inputs to 15 digital inputs in total. Hence, the Arduino Mega would be able to accommodate this arrangement.

PCB design

Did it work out? Unfortunately, our PCB had a low ADC sampling rate. As such, the brief contact of the ball with the piezo sensor resulted in no input registered, despite the potentiometer being turned to a minimum. This led to our box being unable to function.

In the end … we had to source for other alternatives to achieve what we wanted.

Weeks 8-9

Component: Circuitry

Idea: We then considered the loose braiding of piezo wires to detect vibration from neighbouring piezo sensors. This meant that for each concentric circle, only one piezo sensor would be connected to the Arduino circuit using our initial proof of concept idea. Meanwhile, the rest are not connected and the braiding of the piezo wires would allow the vibration to be transmitted. This was akin to a physical manifestation of our multiplexing and grouping idea.

Did it work out? However, the results of our new method were rather unpredictable and inconsistent, as sometimes when the ball hit the sensor an input would be registered but other times it would not. Furthermore, there was no clear way to optimise our mechanism, especially for the unconnected piezo sensors.

In the end … we decided to simplify our ideas to a feasible one that could be optimised.

Component: Circuitry

Idea: In the end, we decided to scale up our piezo piano using 15 analog pins on the Arduino Mega and a breadboard. This meant that for each face of the box, only 3 piezo sensors were connected and had sound/ scores associated with them. The remaining sensors were unconnected.

However, to make things more exciting, we used crocodile clips as a form of temporary connections. This meant that we could switch up the piezo sensors connected for different users/ different rounds of the game.

Final circuitry design

Did it work out? The table below summarises some difficulties we faced, but we managed to devise some algorithms to overcome these difficulties.

Problems and optimisation solutions

To test out our results of optimisation, we selected a sample size of 20 rolls down the ramp, meaning we consistently rolled the ball in the same position down the ramp 20 times. We tracked the number of true positives (hits sensor and makes sound), false positives (doesn’t hit sensor and makes sound), true negatives (doesn’t hit sensor and doesn’t make sound) and false negatives (hits sensor and doesn’t make sound) before calculating values of precision (TP / (TP + FP)) and recall (TP / (TP + FN)).

The results of pre-optimisation (case 1) and post-optimisation (case 2) are shown below.

Results of case 1 vs case 2

In the end … the improved precision shows how optimisation has worked for us, hence allowing us to stick with this circuitry as our final product.

Final Product

Our musical box is hence able to play NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4 as well as the songs Jingle Bells, Crazy Frog, Mario Underworld, Victory theme and Imperial March.