Wednesday, January 17, 2007

How to programmatically cause your Pocket PC to vibrate

I have a Pocket PC Phone Edition device and I want to programmatically cause it to vibrate. How do I do that?

The easiest way would be to use the Smart Device Framework 2.0. The OpenNETCF's Smart Device Framework is an extension to the .NET Compact Framework (.NET CF) and it fills the gap between the full .NET Framework and its subset - .NET CF.

For Smartphones, you can use the Play() method in the OpenNETCF.WindowsMobile.Vibrate class to start the vibration. Unfortunately, this method only works for Smarthphones. For Pocket PC devices, you have to use the notification led to emulate vibration.

The following code shows how to cause your Pocket PC to vibrate for 0.5 second:

Dim vib As New OpenNETCF.WindowsCE.Notification.Led
'---start vibration---
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.On)
'---stop vibration---
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.Off)

The first parameter of the SetLedStatus() method takes in an integer representing the led number. You may need to trial-and-error to find the number that works correctly on your device.

1 comment:

soccer said...

Where do i get the OpenNETCF.WindowsMobile.dll?