Introduction: MUSICAL QUIZ
Hello, we are a group of three students at 4th year module of electronics engineering from University of Malaga, Shool of Telecommunications (https://www.uma.es/etsi-de-telecomunicacion/) and we are going to show you our proyect for the subject called 'Creative Electronics'.
The project consists of a mini-game in which the arduino board decides randomly a melody to play and the player must answer appropriately by clicking on the corresponding push-button; if you press the push-button associated with the song that is playing lights up a green LED and the display count will increase, if not, a red LED lights up and the count is reseted.
Hope you enjoy!
Step 1: List of Materials and Components
1x Arduino Leonardo
1x PCB Board
7x 220ohm Resistors
1x 7-Segment LED Display
1x Tin Coil
1x 5V output power supply (powerbank for example)
These are the materials needed to make the box:
1x A piece of Wood
1x White glue
1x An electric saw
Step 2: Build the Box
First, cut the 4 sides of the box with the measurements (20x5) cm. Then, make the top of the box and the base, with the measurements of the square made with the sides and glue the sides with the base.
Later, place the top with a hinge and make the holes for the buttons, leds and the led 7 segments. Glue the buttons to the top and place the Arduino board on the base with a screw.
Finally, all the components are connected and the photographs of the songs are pasted on the top of the box.
Step 3: Inside the Box
When you got the box, we recommend test the circuit in a protoboard before soldering the PCB board. Note that the buttons use Arduino's PULL-UP resistor by software.
Then connect all push-buttons and the 7seg display to the arduino board using male-female connectors for example.
The arduino board can be powered by an external battery inside the box or directly connected to the PC by a hole in the box if you want.
Step 4: Programming and Blocks Diagram
The main problem is to be able to put many songs without using an SD module and without making the code very long and difficult to manage. For this we have put all the songs in a separate library and we have called from the arduino making a code easy to read and easily modifiable so you can change the songs as you want. The library uses the frequency and silence of each note.
The Arduino code has been made using a switch-case structure. First, a random number is generated and a song associated in that case sounds. If the user presses the correct button, the blue led will light up and the counter will add 1, otherwise the red led lights up and another random song is generated when the start button is pressed.
To compile the code, first you need to zip the .cpp and .h codes, then you will need to import the library into your arduino IDE, Program-> Include library->Add .ZIP library.