31 Days of Windows Phone | Day #12: Making A Phone Vibrate

This post is Day #12 in a series called the 31 Days of Windows Phone.

Yesterday, we talked about the accelerometer on Windows Phone, and how we can pretend to have a real device giving us data.  Today, we’re going to talk about the VibrateController, and how we can give feedback to our users about what is happening with our application.

Because telling someone how to make their phone vibrate immediately evokes tasteless jokes, I’ll let you get them out of your system here, before I have to write “vibration” 15 more times.  Go ahead…I’ll wait.

Why Make the Phone Vibrate?

There’s certainly a great number of silly and/or inappropriate reasons to make a phone vibrate.  For the purposes of this article, however, I’m going to cover some of the specific reasons you’d make the phone vibrate.

Game Feedback

Let’s start with the obvious one: games.  When you’re playing a game, you might not always be able to give the user all of the information they need on-screen.  (Especially when they’ve got their fingers on the screen.)  Giving them “haptic feedback” allows them to know they’re being attacked, or that they need to pay more attention to something important.

Button Feedback

This is probably going to be far more common for you, but for every button you have on your application, haptic feedback lets the user know they pressed the button appropriately.  Default buttons in Windows Phone turn a solid color when pressed, but many times users aren’t certain they made the click (especially if the action takes a few seconds to happen.)  Giving them a quick vibration lets them know they accomplished their goal.


Another obvious, but underused opportunity for vibration feedback is notifications.  By default, if you get an email, text message, etc., your phone vibrates (or makes a noise).  We should leverage that same user experience in our applications.  When the user should be alerted to something, make the phone vibrate.  This is especially important when your application is a passive one.  For example, an application that tracks your location as you run through your neighborhood.  If it loses a signal, or perhaps you reach your target distance, a vibration would let the user know, without looking at their phone.  In that same example, you could even give them feedback each 1/4 mile, so that they’re aware of how far they’ve gone.

How Do I Make the Phone Vibrate?

Thankfully, this is incredibly simple.  You need two lines of code to make it happen, but you should spend a significant amount of time tweaking this to your specific needs.  Here’s the basic code:

VibrateController vc = VibrateController.Default;

How long should I make it vibrate?

There aren’t any specific rules about how long vibration should happen for a specific notification, but I have some guidelines I follow, and I’ll share them with you:

  1. 1/10 of a second is the appropriate amount of time for a button press.  (It’s also the shortest amount of time the VibrateController can vibrate).
  2. 2 seconds = “WHAT IS WRONG WITH MY PHONE?!??!?” to your users.  2 seconds is WAY too long for any single notification.
  3. 300 milliseconds (~1/3 of a second) seems to be a good amount of time for one steady notification vibration.  It gets your user’s attention without making them think that something is wrong with their phone.
  4. Quick pulses of vibration are another great way to let the user know what is happening.  I have included this example in my sample code download below, but for a clearer explanation for how I’m doing it, check out my tutorial on “How To Create A SetTimeout Function In Silverlight.”

Download the Code

We’ve got some heavy-duty topics coming up in the next few days, including Location Services and Tombstoning.  Please leave a comment on any of the posts in this series to let me know what you think!


11 thoughts on “31 Days of Windows Phone | Day #12: Making A Phone Vibrate

  1. Still reading through your 31 days of WP and still finding it really useful. It’s very clear and well-written. Great job!!

  2. The older I grow the more I distrust the familiar doctrine that age brings wisdom.

  3. It is better to be hated for who you are than to be loved for what you are not.

  4. I was looking for some site which would explain about haptics and voila!
    Search and thou shall find😀
    Precise and well written!!😀

  5. Pingback: Vibration Behaviors for Windows Phone – Part 1 | Xyzzer's Dev Blog

  6. This demonstrates the feature well. I haven’t read all your articles in these series, yet (but have started). Is there somewhere I can find out how to use the intermittent beep as a cancellable vibrating alarm? (I’m unsure on how the events would work for the Cancel operation.)

  7. Thanks. Short, sweet and precise.

    Just want to confirm if there are any certification requirements when using vibrate with WP 7.1?

  8. Awesome Stuff ! Hats Off !!🙂

  9. In XNA 4.0 for WP7.X, devs could set the vibration intensity of the phone using the Microsoft.Xna.Framework.WindowsPhone.Input.GamePad.SetVibration(player, leftMotorStrength, rightMotorStrength) function prior to calling VibrateController.Start(). This was useful for force-feedback in games. Do you know if there a similar function for setting the vibration intensity in Silverlight or C#+XAML for WP7.X or WP8 apps/games?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s