Arduino Forum

Using Arduino => Project Guidance => Topic started by: Vincent19 on Jul 18, 2013, 04:30 pm

Title: A Mini Piano
Post by: Vincent19 on Jul 18, 2013, 04:30 pm
Hey guys, I plan to make a mini piano with maybe like 8 buttons for 'Do, Re, Mi, Fa, So, La, Ti, Do'

So what I want is just basic first. When I press a button then the speaker will give 'Do', then another button give me 'Re'

I know it is quite simple to do, just I dont have any ideas on tones in arduino.

Hope I can get some helps here.

Thank you in advance :)
Title: Re: A Mini Piano
Post by: HazardsMind on Jul 18, 2013, 04:58 pm
You need to look at the Tone example. From there you can see the it needs a certain library that has all the tones in it. Now once you understand how that example works, you can modify it to output a tone if a certain "pin" goes HIGH and go silent if the pin is LOW.

Also if your familiar with a normal piano, Do to Do is an octave, and there are also different scales that you can program into the code too, if you want to get fancy.
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 18, 2013, 05:04 pm

You need to look at the Tone example. From there you can see the it needs a certain library that has all the tones in it. Now once you understand how that example works, you can modify it to output a tone if a certain "pin" goes HIGH and go silent if the pin is LOW.

Also if your familiar with a normal piano, Do to Do is an octave, and there are also different scales that you can program into the code too, if you want to get fancy.


What do you mean by the bolded part ? Somehow confuse.

Thank you
Title: Re: A Mini Piano
Post by: KeithRB on Jul 18, 2013, 05:23 pm
You are the one that started with Do, Re, Mi...
He means that from Do (C) to Do(C) is an octave on the piano keyboard.
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 18, 2013, 05:28 pm
Okay, you mean program the Do for different frequency ? I do not have music background. So sometimes I do not understand what you tell me.

But I will learn.

Thank you
Title: Re: A Mini Piano
Post by: KeithRB on Jul 18, 2013, 06:16 pm
Start here:
http://arduino.cc/en/Tutorial/Tone
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 19, 2013, 03:35 pm
I am sucks in music frequency stuff. Can anyone tell me the basic one and their frequency ? How many buttons needed ?

Thanks !
Title: Re: A Mini Piano
Post by: RamJam on Jul 19, 2013, 09:01 pm
Take an oscilloscope. Stick microphone in scope. Hit C on piano, measure frequency. Then hit next note and so on up to octave above. Program Arduino to emit said frequency in accord to button pressed.
Title: Re: A Mini Piano
Post by: 1ChicagoDave on Jul 19, 2013, 09:16 pm

Take an oscilloscope. Stick microphone in scope. Hit C on piano, measure frequency. Then hit next note and so on up to octave above. Program Arduino to emit said frequency in accord to button pressed.


Right, because it sounds like he probably has an oscilloscope just laying around.....?

Or....google "music note frequency" and find something like this -
http://www.audiology.org/news/interviews/documents/chasinconversionchart.pdf (http://www.audiology.org/news/interviews/documents/chasinconversionchart.pdf)

Then, follow the tone and button tutorials to figure out the rest. 
Title: Re: A Mini Piano
Post by: BulletMagnet83 on Jul 19, 2013, 09:28 pm
You're going to need at least 13 buttons if you want to play anything interesting ;)
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 20, 2013, 04:59 am
What are the 13 buttons and frequency ?

Thanks
Title: Re: A Mini Piano
Post by: BulletMagnet83 on Jul 20, 2013, 03:22 pm
http://www.phy.mtu.edu/~suits/notefreqs.html

Remember, there are 13 keys in each "octave". The sharps and flats allow you to play in any key without re-tuning.

That table should do it! Although I don't think you can use float values in tone(), so if you care about having it properly in-tune, you may need another approach. If not, just bang in the closest value rounded up or down to suit, and hope for the best.
Title: Re: A Mini Piano
Post by: RamJam on Jul 20, 2013, 03:47 pm


Take an oscilloscope. Stick microphone in scope. Hit C on piano, measure frequency. Then hit next note and so on up to octave above. Program Arduino to emit said frequency in accord to button pressed.


Right, because it sounds like he probably has an oscilloscope just laying around.....?

Or....google "music note frequency" and find something like this -
http://www.audiology.org/news/interviews/documents/chasinconversionchart.pdf (http://www.audiology.org/news/interviews/documents/chasinconversionchart.pdf)

Then, follow the tone and button tutorials to figure out the rest. 


Yes but we want this guy to think for himself don't we? If he wants help I think he should present his idea in its entirety so that we can add suggestions. What is this little piano to look like? What are its features to be? How big is it intended to be? Who's it for, us or a specialised niche?  All this needs to be revealed so that we can all co-operate. We need to give him a reason to reveal his vision, but if we just hand out easy fixes on tap he will disapeer like all the others and we'll be left with yet another inconclusive thread.
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 20, 2013, 04:00 pm
Hey all, this is my plan :

I plan to do a mini wireless piano where the speaker is wireless. And it is able to play the Happy Birthday Songs. Besides, it is the best if it can play some others songs/melody. I made this for my friend during her birthday as gift.

Hope it is clear.

So, any suggestion on how many and what keys should be included to make it somehow impressive piano that can play quite a number of melody ?

Thank you
Title: Re: A Mini Piano
Post by: RamJam on Jul 20, 2013, 04:18 pm
Hopefully at this stage you are drawing artist impressions on how the finished article will appear.  Presumably you want the unit so that the user can enter in and hopefully edit any now song that comes to mind via controls on the unit? You would like it capable of connecting to an external speaker / amp set up? That bit is probably the easiest - if you start by using a 1/4" jack socket and consider the nature of how it will transmit wirelessly as an upgrade. Will the unit have provision to plug in headphones to use as a standalone?
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 20, 2013, 04:23 pm
It is just a simple wireless piano where I will be using a normal low cost RF 433MHz. I would probably have the basic 8 keys do,re,mi,fa,......Then user can press the button then the speaker on the other side would sounds.

Thats my idea.

Thank you
Title: Re: A Mini Piano
Post by: RamJam on Jul 20, 2013, 09:23 pm
Presumably it will use an arduino controller board? Presumably other people will want one of these as well so as to join in? My hand span from thumb to smallest finger can stretch to 8.5" but relaxed it is 6" down to 5" so I can fit thumb and all 4 fingers into a rectangle that's 5 5/8ths" x 3". So we can start by drawing a rectangle to those dimensions and see where the fingers on the right hand naturally settle for the first 5 notes of the c major scale from c to g. Then mark out a grid that intersects at each finger.

Don't patent it. Open source it!
Title: Re: A Mini Piano
Post by: Vincent19 on Jul 21, 2013, 07:09 am
I just plan to do a mini piano that using one hand to play onlad of two :)))
Title: Re: A Mini Piano
Post by: 1ChicagoDave on Jul 21, 2013, 09:20 am
http://makezine.com/2008/05/16/build-the-arduino-pocket/ (http://makezine.com/2008/05/16/build-the-arduino-pocket/)

EDIT:
My bad, looks like that kit is no longer available, and I can't find any schematics for it either. But, at least there's a part list & photos to give you an idea where to start. It should be simple enough to reverse engineer/modify to suit your vision. Though, as cheap as tactile switches are (I've got about 100 I got FREE by just taking apart other things before throwing them out!), might as well build the full keyboard. That is, the white and black keys - All semitones vs. just whole notes.
Title: Re: A Mini Piano
Post by: boguz on Jul 21, 2013, 01:34 pm
Sounds like a fun project!  8)

The problem with having 8 buttons is that you will be stuck to one "key".
So for example if you have the notes Do, Re, Mi, Fa, Sol, La, Si, Do you will be stuck playing in Cmajor (you could also play in Am and in a couple of different modes, but that's a different story...).

If you want to play the "Happy birthday" song, and you want to start with Do, it means you need to play it in the key of Fa Major.
This means you would need to use the notes:
Do, Re, Mi, Fa, Sol, La, Sib, Do.    <---  Notice the Si is FLAT!

You can take a look at the frequencies here:
http://www.phy.mtu.edu/~suits/notefreqs.html

I guess a nice Octave would be from C4 to C5, but you can try and see which one you like the best...

Have you decided on your circuit?
Maybe the easiest way for you to play the notes is with the tone() command.
You can see here how it works:
http://arduino.cc/en/Tutorial/tone

And here you can see an example of a simple "piano" with 3 buttons. Maybe you can adapt it to your project!
http://arduino.cc/en/Tutorial/Tone3

When you have something ready, post your code and we can help you more from there!
Good Luck!
=)
Title: Re: A Mini Piano
Post by: RamJam on Jul 21, 2013, 03:38 pm
If you wanted to have 2 or even 3 octaves 37 notes and it was monophonic you could arrange 3 buttons to behave like valves on a trumpet for one hand and 4 buttons for the other hand. In combination modelling the 3 based on trumpet and the other for for different blows. You could use a strap to slip one hand to hold unit and etc. this makes it very small and only 7 buttons.
Title: Re: A Mini Piano
Post by: 1ChicagoDave on Jul 21, 2013, 04:06 pm
Quote
The problem with having 8 buttons is that you will be stuck to one "key".
So for example if you have the notes Do, Re, Mi, Fa, Sol, La, Si, Do you will be stuck playing in Cmajor (you could also play in Am and in a couple of different modes, but that's a different story...).

If you want to play the "Happy birthday" song, and you want to start with Do, it means you need to play it in the key of Fa Major.
This means you would need to use the notes:
Do, Re, Mi, Fa, Sol, La, Sib, Do.    <---  Notice the Si is FLAT!


Or, play C scale...starting with G. (Technically, "G Mixolydian"....but I digress.)(I'm sure what you were thinking by mentioning modes)

Though it's easy enough to transpose, too.

By adding a simple pot, or extra button to project...could access different scales easily. (Though, I think this is may be more complex than OP intends or wants.)

Here's example of simple, whole note version of "Happy Birthday".
Title: Re: A Mini Piano
Post by: DuaneB on Jul 21, 2013, 05:22 pm
Hi,

Why not hack a cheap keyboard, I used a 37 key one, but i have looked at smaller ones with 1 or 1 and a half octaves.

http://rcarduino.blogspot.com/2012/10/five-dollar-synthesiser.html (http://rcarduino.blogspot.com/2012/10/five-dollar-synthesiser.html)

Duane B
rcarduino.blogspot.com (http://rcarduino.blogspot.com)
Title: Re: A Mini Piano
Post by: RamJam on Jul 21, 2013, 05:35 pm
If it were my project I can see my way to assembling the electronics of the thing. Finding suitable chips and putting the bits onto a pcb. I can see my way to programming it up. That's easy. What is not easy is making it kinaestheticly useable. Once the project is complete it should have a use. In this case it should enable the users to create music, so the instrument needs to be playable and have some kind of visual and tactile appeal and ease of use once completed. This leads one to question what the buttons should be shaped as? Where should they be positioned? Will it power off AA batteries. Are their options to charge and install new firmware via USB, Bluetooth etc.

I think the guy said he wanted it wireless so that would mean a Bluetooth shield. So the things got to have space for at least 2 boards, probably more to future proof it. There's nothing worse than spending months or years of hard work on a project only for it to be dumped into the scrap box immediately on completion due to its over dedicated and inflexible design.
Title: Re: A Mini Piano
Post by: 1ChicagoDave on Jul 21, 2013, 06:40 pm
Quote
What is not easy is making it kinaestheticly useable. Once the project is complete it should have a use. In this case it should enable the users to create music, so the instrument needs to be playable and have some kind of visual and tactile appeal and ease of use once completed


All that information can be found in a book called "A Measure of Man and Woman". Pretty handy piece of work!

Quote
I think the guy said he wanted it wireless


I think they also said they wanted to make one of these to give to a female friend for her birthday. I don't think they want to create a new, mass-produced product, to introduce to the marketplace. So, I would assume (understanding women as little as I do) that it just needs to "work" (play Happy Birthday, etc...) and show they put an effort into it. Sorta more like, "it's the thought that counts" kinda thing?
Title: Re: A Mini Piano
Post by: RamJam on Jul 22, 2013, 09:55 pm
Women? Oh. Why not just make her a birthday cake?
Title: Re: A Mini Piano
Post by: KeithRB on Jul 22, 2013, 10:34 pm
For the Notes and Frequencies, just look at the notes.h file included with the tone example above. You didn't even bother to try it, did you.