Introduction
This will explain how you can make an instrument move up and down scales using just pitch bend, and the magic of MIDI!
Possible scenarios for this might be = ... (e.g. if you want to emulate a guitarist doing that fretty thing or whatever it is)
First I'll say a bit of theory, then how I worked it out, and then go on to demonstrate it in practice.
Introduction Continued (Sola's text starts here)
Well, I looked around here and didn't see any information about this subject, so I thought I'd craft a little tutorial/discussion about it, and then give a boring lecture on it for the next half-hour.
By the way, I use Cakewalk Music Creator 2003 when I'm working with midi events (Anvil Studio when I'm not), so all of the following screenshots will be of the Cakewalk program. Therefore, I don't know how well (if at all) my tutorial will translate into your own sequencing program.
Oh, a word of warning, for those of you who already know a bit of music theory (I imagine most readers here already do), a lot of this will sound incredibly familiar. So you can just gloss-over/tune-out those parts when I get to them.
Alright, here we go
Up until December of last year, I had no idea how to do pitch bends.
Even though, prior to that time, I had attempted to sequence music with pitch bends, I never really had the motivation to truly try and figure it out until I came across a certain song which I really wanted to sequence.
This particular song has sliding and hammer-ons in the bassline. Stuff that I was surprisingly not used to. Surprising because I'm a bassist, although I hardly practice it these days, so that might explain my lack of familiarity. And despite this, I still have the audacity to call myself a bassist, heh.
Anyhow, this song that I really wanted to sequence (and am still in the process of sequencing... it's getting there) finally gave me the motivation to learn pitch bends and so, after looking at various midi files with bends, I did some trial-and-error, crunched some numbers, and came up with a nice equation.
Pitch Bend Equation

Now I'll tell you what this means in just a minute, but before I do that, I need to explain some things.
If you look at the events list in a midi file containing pitch bends, you'll probably notice that it's full of all sorts of events. In Cakewalk, for instance, the events are color coded: black for notes, reddish-pink for controllers, RPN, and light-blue for changes in the pitch wheel.
In this first screenshot, I have "RPN" selected. Using the Kind of Event window, I can change this event to a different kind of event. I'm not going to though, since it's already an RPN event like I want it to be.

If you'll notice in this next shot, under the 'Data' column, I have selected the value 0 (zero). This will make your generic RPN event into a Pitch Bend Sensitivity event so you'll probably want to set it at zero too (that's why you're reading a Pitch Bend tutorial, isn't it?), and I'll explain more on this later.

In the screen shot below, the value which I have highlighted is what I refer to as the as P variable. It's the same "P" as in the PBE (pitch bend equation) above. Why did I choose to refer to this value as "P"? Answer: Pitch bend. So, in this example P=2048

In the following screenshot, I have selected the t variable. In this case, t=512, and I'll explain this next.

Now, what is so special about the 't' value/variable anyway?
Well, the 't' value, represents the increment of change of one Half Step, also known as a Semitone, on the pitch wheel.
A semitone, is one twelfth of an octave. In other words, twelve of these semitones, one after another, make up what known as the chromatic scale
Now, I don't know about you, but I like the chromatic scale. I like it a lot. When I am working on music, I think in terms of the chromatic scale. Diatonic scale? No thank you sir, not for me. Sure, need it for understanding all those modes (Aeolian, Ionian, Phrygian, etc) But when I'm sequencing, thinking about modes feels like more trouble than it's worth to me.
One reason that I like the chromatic scale is because the distance between each note on the chromatic scale is, logarithmically, the same (err, for the most part). Also, it's easier for me to think in terms of the chromatic scale, especially since my electric bass is divided by its frets into half steps.
Also, half steps are simply the best starting point from which to do pitch bends (yes it's just my opinion).
You can, and should, use fractions of a semitone when necessary. Fractions are good for stuff like, trumpets, trombones, other brass stuff... ok so I can't think of any more off the top of my head but that's a good start, right?
Back to the PBE: Quick Review
P=your PBS (Pitch Bend Sensitivity) value (highlighted in the 3rd screenshot above).
t=the value of a semitone for a Pitch Wheel event (highlighted in the 4th screenshot above).
2^(20)=is a constant equal to 1,048,576
So this pitch bend equation is actually pretty easy, right? Just two variables and a constant. Speaking of the constant, if you don't like how it's written, you can also try writing it as
or 
Personally I prefer to remember it as "two to the power of twenty", but just go with whatever you personally can remember.
One more thing you should have noticed by now, is that, since 't' is inversely proportional to 'P', (yeah, I know it's obvious), you can just switch the P & t variables of the equation, and it's still true:

Anyway, this equation, where you solve for t, instead of for P, is actually the one you'll use most often. If you're plugging in different PB Sensitivity values, you'll probably want to know what the Pitch Wheel Semitone value is going to be, after all, and how many octaves a specific P value will make available to you.
Hey, I respect everyone's intelligence (even though I may not sound like it in parts of this tutorial). Some midi sequencers start when they're like 12, and if they see this, I want them to notice it too, because as obvious as this is to most of us, it's good if every sequencer notices.
Here's one final way of thinking of the PBE:

Since P multiplied by t always adds up to the same constant, 1,048,576, it can be a quick way of double-checking that you have the correct t value for a given P value (and vice versa). Like, hmm, is a 't' 682.67 correct for a 'P' of 1536? Well, 700 times 1500 equals 1,050,000, so that's probably right.
What values for P are possible?
It's possible to set P to any number between 0 and 16383. That's said, values ranging from 128 to 3072 are what actually make the Pitch Bend Sensitivity event useful and are the values affected by the pitch bend equation.
0-127
Any value of P between 0-127 will simply negate all wheel movements. In other words, there will be no bending at all, even if you have a bunch of wheel events. Obviously, it's pointless to do this because you will have simply rendered all of your fancy wheel movements useless, thereby making them a redundant, unnecessary waste of space. Kind of like me, hahaha.... =(
128-3072
As already stated, these are the values which are actually useful to us sequencers, however there is one exception, as I'll explain in the next sentence.
256
256 is a special value. At a P value of 256, the t value for a pitch wheel event is set at 4096. The thing is, this is the same value of a semitone even without the PB Sensitivity event, so it's the same as if the Pitch Bend modifier were not even there.
Just as a P value of 0-127 renders all wheel events useless, in a way, the 256 renders the Pitch bend event itself useless. This of course assumes that you only use 256 throughout your whole song. If you were to change the Pitch Bend Sensitivity to 256 from some other previous value that you placed earlier in your song, then 256 would be useful for you. Personally, I've never done this since I only ever need to use one sensitivity setting for the whole song.
3072-16383
At 3072, you can bend a note 4 octaves (-8192 to 8191). Any P value above 3072 (3073-16383) is still the equivalent of having your PB Sensitivity set to 3072. Doesn't matter whether you set your P value at 4096, 8192, etc, it's still the same as if it was set at 3072.
So, four octaves is all you get in midi. And honestly, do you really need to bend more than that? I'm not sure I'd even want to listen to a note that bends more than 4 octaves. =)
RPN Data Value
Remember that RPN value under the 'Data' (if you don't go back and look at the second screenshot again). Well, even though this isn't all that important, in my opinion, I thought I'd share what I know about it. (actually, I'll finish this part later)
Pitch Wheel Event Values
Well, we've established that t is a half step. But what about other values? Well, all we need to do is use multiples of t.
If you'll look back at any of the first four screenshots, you'll notice that it has pitch wheel values descend from 3584 on down to 0. If you'll recall, the "t" value in that case was 512 (due to the PB Sensitivity value of 2048). That means the G 3 actually starts 7 half steps higher, at a D 4, and descends to a G 3 in approximately and a quarter note of duration.
But wait, why end it on a zero?
Well, this should be pretty obvious. It sounds better!
Allow me to elaborate- if the note being bent terminates the bend at zero, then you don't have to worry about squeezing in another pitch wheel event with a "zero" value before the next note comes in right after the one you were bending (what I will refer to as 're-zeroing'). What this means though, is that, in order to make a bend that ascends in pitch, you'll have to start at a negative pitch wheel value to raise your pitch (as opposed to starting at zero, going to some arbitrary positive number and re-zeroing at the last possible millisecond (I see this a lot *facepalm*).
Also, ending on zero prevents your note duration from being less than the full amount that you want it to be (re-zeroing can make it 959 instead 960 ticks). Yeah, it may not seem like a huge difference, but some people use timing set at less than 960 ticks for their quarter notes. If it's made short enough, then it can make an audible difference!
Now, granted, this it isn't always possible to avoid re-zeroing, but the only instance, as far as I know, where you won't be able to end at zero is when you're bending a note more than two octaves before terminating it (as P value 3072 will give you two ascending octaves for -8192 to 0, and two descending octaves for 8191 to 0).
Here are a couple of pictures demonstrating improper re-zeroing and the proper solution to it. (persons who's work is used as an example shall remain anonymous)
Notice how, in order to descend in one octave in pitch, the person chose to start at zero and use negative wheel values, and then they had to tack on a zero at the end:

Next, this is the same motif (albeit, in a different section of the song), but I've tweaked it to start at a positive value and arrive at zero.
Important: In the picture below, please notice that the note being bent (selected inside the red box) is a C3 and not a C4 as in the previous picture. In both cases, the bend starts at C4 and ends on C3, but since the wheel events below end on zero, then they consequently must end on a C3. So, C3 must be the zero value (whereas above, C4 is the zero value).

Let me give an example of this:
A P value of 2560 sets the 't' variable at 409.6. Unfortunately, decimal values can't be entered for events. So, what we will have to engage in is known as "rounding."
Rounding!
Actually you should know how to do that already if you're old enough to use a midi sequencing program. That said, there's a (not so commonly known) standard technique if you should arrive exactly on a .5 value, and that is to round to the nearest even number. So, if you get 402.5, round down to 402. If 403.5, then round up to 404.
So, instead, I'll just put up a picture instead to illustrate fractions of a semitone. In this particular screen shot below, the wheel events are divided into 50 cent pieces (50 cents being half of a semitone). The total amount that the note is bent is 3 octaves.
<---The image is too long to thumbnail, So you have to click a link instead. =/Please notice how I wasn't able to terminate the note on a zero, but instead on a 6554. And the when it repeats (more quietly), it has to jump back down to -8192. Here's a midi of it.
Summary:
So basically all you need to do is enter RPN values (this and that) and then to bend up a semitone you move it up 50 cents, to go up an octave it's 650, etc.
F.A.Q.
Q)So, how'd you figure this stuff out?
A)Trial and error. Opened a few midi files that had different PB Sensitivity values, and then just did some experimentation and calculations using notepad and calculator. I still have the notepad file that I used as a scratchpad and it's here if you want to read it - have fun deciphering it.
Q)Why should I only use whole 't' values for things like guitars? (Edit: thanks to HyperX for pointing out my ignorance here, wish someone had done it sooner so I wouldn't have looked like a fool for two weeks, lol)
A)You shouldn't. On fretted guitars, when you fret a guitar note normally, you will move in only semitone increments, however guitar strings can also be pulled to the side and oscillated (for vibrato) by the fretting hand, giving fractions of semitones.
Q)So, I can use wheel events to make my instruments sound out-of-tune?
A)Err... yes, but... why would you want to? Sure, it might make your instruments sound slightly more realistic, but there's a danger of over-doing it and just ending up with something that sounds quite unpleasant. O_o
Well, that's it
(I'll go back and finish that one section later on RPN 'data' values later.)
I welcome comments and criticisms. Please let me know if I got anything wrong (I'm still quite a n00b when it comes to events) and ways that I could improve this, such as any ways I can say things/describe things differently. Like I previously mentioned, I haven't used any other sequencers except for Cakewalk (and Anvil Studio) so I don't know how well (if at all) this information can be adapted to one's own sequencing program.
Also, if this has been helpful to anyone, please don't hesitate to say so. If this helps even one person, then I'll have felt it was worth it for me to have written it.


