@Silverpool So I'll try to provide a bit of an explanation and link to some resources.
You're a pianist, so that will make things much easier to explain.
I assume you know the notes on the instrument? Here is a chart.
• So all of the white keys, going from C to B, form the "C Major Scale". This gives you 7 notes to work with. A distance of two tones, counting the black keys too, is a "whole tone" or "whole step"; a distance of only one key between notes is called a "semi tone" or "half step." Since "C" is what we're using as the basis to create the scale, we will refer to C as the "tonic" or "root" note. Notice that between E & F as well as B & C, there is only a half step but no "sharp" black key. As such, there is no B sharp or E sharp. The distance between two notes is referred to as an "interval".
• The formula to create the major scale, in any key, starting from the root note, is: Whole step - whole step - half step - whole step - whole step - whole step
• Starting from any note you choose on the keyboard, this formula will give you the major scale for that key.
• Now, if you count three keys down from the "root note" of your major scale, you will get the minor equivalent. In the case of C Major, counting three keys down, the note is "A". So, all of the same notes as the Major scale, but instead is "minor". It has a different sound, trying playing all white keys from C to the next C note; then, try playing all white keys from an A note to the next A note, and you will hear the difference in sound.
Congratulations, you now know the musical scale used to create ostensibly all of western music!
But why is one major and the other minor, you ask?
The answer has to do with "triads" (three-note chords) that can be built from the "root" of the scale.
To form a "major triad", start from your root note, and count up four keys. This will give you the "third" interval of your root note; a "major third" specifically. From this major third, count up 3 more keys, and you will get the "fifth" of the root note. In C, this gives us C, E and G.
To form a "minor triad", start from your root note, and count up 3 keys. This will give you the "minor third" interval of your root note. From this "minor third", count up 4 more keys to get the fifth of your root note. In "A", this gives us A, C, and E — an "A minor chord." So, you count "4 - 3" to form a major triad, and "3 - 4" to form a minor triad. Easy, right?
• If we apply this formula to all of the notes available to us in the scale, we can form 7 basic triads. Starting with the root in C Major, we get:
C Major, D Minor, E Minor, F Major, G Major, A Minor.
You will notice that this is only six triads. The reason that the B triad is omitted, is because it is a "diminished" chord. If you use the counting formula, you will notice that F# is the fifth of B and NOT simply F. F is a half step lower; a fifth that has been lowered by a semi tone is considered "diminished" and a diminished triad sounds "dissonant" or unstable.
• Melodies, the "tune" of the song, are constructed from the scale as well. To harmonize a melody, all one must do is match the notes of the melody to chords they belong in. For example, a melody note of "C", in C Major scale, could be part of a C major triad, an A Minor triad, or an F Major triad, as the C note is present in all of them.
To practice this, try coming up with a simple melody using only quarter or half notes. For each note you play, play a matching chord with your left hand.
The practice of changing chords to a specific rhythm, is called a "chord progression" and certain chords "prefer" to move to certain other chords.
• Once you are comfortable with this, you can move onto more advanced subjects.
Including:
Creating basic chord progressions
Using notes not found in the current chord in your melodies
The harmonic series, or why you should use wider intervals in the lower register and closer intervals in the higher register.
How to smoothly change chords by using "inversions" (the notes of the triad played in a different order)
Extended chords and harmonies created by combining different intervals to create more complex chords
The seven church modes
and how harmony works when "fifth" and "fourth" intervals are stacked to create chords instead of thirds.
Hope this helps!