Haptic feedback is the way to convey information to users using advanced vibration patterns and waveforms. Earlier consumer electronic devices communicated with their users using audible and visual alerts, but now things have been replaced with vibrating alerts through haptic feedback.
In a haptic feedback system, the vibrating component can be a vibration motor or a linear resonant actuator. The motor is driven by a special hardware called the haptic controller or haptic driver. Throughout this chapter we use the term vibrator for the vibration motor.
Adafruit DRV2605 haptic controller is an especially designed motor controller for controlling haptic motors. With a haptic controller, you can make various effects using a haptic motor such as:
Vibrators come with various shapes and driving mechanisms. Some of them support haptic feedback while some do not. Before purchasing a vibrator, check the product details carefully to determine whether it supports haptic feedback. For this project, we will be using a simple vibrating mini motor disc, which is a small disc-shaped motor. It has negative and positive leads to connect with the microcontroller board.
The following image shows a vibrator with positive and negative wires soldered:
Use the following steps to connect the DRV2605 haptic controller to Arduino WiFi Shield:
The following image shows the connection between DRV2605 breakout board and Arduino WiFi shield:
On the DRV2605 breakout board, you can see two square shaped soldering pads marked as + and - along with the motor text label. This is the place where we are going to solder the vibrator. Generally vibrators have two presoldered wires, red and black.
The following image shows the final connection between DRV2605 breakout board, Arduino WiFi shield and the vibrator:
You can download the latest version of the Adafruit DRV2605 library from the GitHub repository by navigating to the following URL: https://github.com/adafruit/Adafruit_DRV2605_Library.
After navigating to the earlier URL, follow these steps to download Adafruit DRV2605 library:
Adafruit_DRV2605
. Then copy or move the folder inside the Arduino libraries folder. Finally, restart the Arduino IDE.You can download the datasheet for DRV2605 Haptic Driver from http://www.ti.com/lit/ds/symlink/drv2605.pdf and refer to pages 55-56 for the full set of 123 vibration effects. The DRV2605 haptic driver is manufacturing by Texas Instruments.
Now, we will learn how to make different vibration effects depending on the Received Signal Strength Indication (RSSI). Typically, RSSI value rages from 0 to -100. The higher the value, the stronger the signal reception where 0 is the highest value. Therefore, we can logically check the RSSI value return by the WiFi.RSSI()
function and play vibration effects accordingly.
In the following example, we will play the first 10 vibration effects according to the RSSI value output by the Arduino WiFi shield. See the following chart for the RSSI value range for each vibration effect:
Effect Number |
RSSI | |
---|---|---|
1 |
0 |
-10 |
2 |
-11 |
-20 |
3 |
-21 |
-30 |
4 |
-31 |
-40 |
5 |
-41 |
-50 |
6 |
-51 |
-60 |
7 |
-61 |
-70 |
8 |
-71 |
-80 |
9 |
-81 |
-90 |
10 |
-91 |
-100 |
Following steps shows how to generate different vibration effects according to the RSSI strength of the currently connected Wi-Fi network.
B04844_02_06.ino
from the Chapter 2
sample code folder.char ssid[] = "MyHomeWiFi";
map()
function:int range = map(rssi, -100, 0, 1, 10);
setWaveform(slot, effect)
function by passing the parameters such as slot number and effect number. Slot number starts from 0 and effect number can be found in the waveform library effect list.go()
function to play the effect.The following code block shows first how to set and play the waveform double click – 100%
:
drv.setWaveform(0, 10); // play double click - 100%drv.setWaveform(1, 0); // end waveform drv.go(); // play the effect!
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
3.22.216.59