Introduction: PIANO (TONES) MEMORIZE AND PLAY USING ARM MCU.
This is a simple project, you have 16 buttons each one records a specific tone when pressed, which can be played in the same pressed sequence when pushing a play button.
Step 1: Microcontroller- Development Board :
I used the STM32 full-featured development board with MCU card containing STM32F107VCT6.It contains many on-board modules necessary for development variety of applications, including multimedia, Ethernet, USB, CAN and other.
You can find more details, User Manual, Schematics and examples here.
If you want to get started with the board or for any ARM supported architecture you can check this video.
or you can check this un-boxing video for a similar product.
For this project we're going to focus on the buttons and the buzzer. This board contains 5 PORTS for buttons which can be configured as inputs or outputs. Pin 14 in PORTE is the buzzer pin.
We will use PORTD both /H and /L for the 16 input buttons. and PORTB/L pin0 for the input play button.
Step 2: Code Steps :
First we need to program the PORTS as inputs or outputs, you can program the whole PORT or just the pins you're going to use.
PORTD and PORTB --> INPUT
PORTE --> OUTPUT
The idea of the code is to quickly and continuously check if any of the buttons is pressed, if true, the number of the button (Button 0 or 1 till 15) is saved in an array and so on in the same sequence pressed. These numbers are converted to frequency values and saved in the array. The array is then sent to the buzzer Play function to play the tones.
- The Button and Sound libraries help make the code much easier, don't forget to include them.
- For my project to convert the button numbers to frequency values, I multiplied the button number by 150, you can choose any other value.
- In function Sound_Play(,) the second parameter is the period of time a tone keeps playing in msec, so it's up to you.
attached here is a file containing the code with comments for further explanation.
Step 3: Upload the Code and Play
build and program the code to the MCU using your IDE.
These two videos are trials for the project where:
in (1) the tones play continuously without a break.
(2) the tones are separated with a Delay_ms(100); between each Sound_Play(,) loop iteration.
If you have any questions or any troubles understanding/uploading the code or the whole kit, write a comment or contact me : email@example.com
We have a be nice policy.
Please be positive and constructive.