Qwiic Haptic Driver DA7280 Hookup Guide
Contributors:
bboyho, Elias The Sparkiest
Example 2: PWM Mode
Note: The Haptic Driver IC requires that the PWM signal frequency given to
Since the library version is not included in the Arduino Library Manager, you will need to manually install the TimerOne library by Paul Stoffregen by downloading it from the GitHub repository. In the Arduino IDE's menu, navigate to Sketch > Include Library > Add .ZIP Library.... A window will open up requesting for the ZIP file to be included. Head to the Downloads folder where the TimerOne-master.zip is saved.
GPI0/PWM pin
is at least 10kHz. The default PWM methods of analogWrite()
does not provide a method of controlling the frequency of the PWM signal. To use with the RedBoard with ATmega328P, you will need to use the TimerOne Arduino Library by Paul Stoffregen. Note that this library is limited to certain boards. For the Arduino Uno (e.g. the RedBoard with ATmega328P) the PWM pins that are reserved are on pins 9 and 10.
Since the library version is not included in the Arduino Library Manager, you will need to manually install the TimerOne library by Paul Stoffregen by downloading it from the GitHub repository. In the Arduino IDE's menu, navigate to Sketch > Include Library > Add .ZIP Library.... A window will open up requesting for the ZIP file to be included. Head to the Downloads folder where the TimerOne-master.zip is saved.
We're just going to look the PWM_Mode_Timer1.ino example. Open the File > Examples > SparkFun Qwiic Haptic Driver DA7280 Arduino Library > PWM_Mode_Timer1.ino. Select your board (in this case Arduino Uno) and COM port. Then hit the upload button.
Once uploaded, the Qwiic Haptic Driver will first clear a flag that shuts the motor off if the PWM signal is cut off suddenly without being set into inactive mode. The motor will begin vibrating based on the PWM signal in the for
loop. In this case, the PWM signal is dependent on the value for power
and we slowly increase the intensity.
Note: Unlike the RedBoard with ATmega328P that requires the Timer1 library, you can also choose a microcontroller that has the ability to control the frequency of the PWM signal like the Teensy or Artemis. These have more power. For more information, check out the File > Examples > SparkFun Haptic Driver Arduino Library > PWM_Mode_Teensy_Artemis.ino.
You will need to install the Teensyduino for Teensy or the Ambiq Apollo3 board definitions (v2.0.6+) for the Artemis if you decide to use the example. Once installed, make sure to select your board and COM port before uploading the example.
You will need to install the Teensyduino for Teensy or the Ambiq Apollo3 board definitions (v2.0.6+) for the Artemis if you decide to use the example. Once installed, make sure to select your board and COM port before uploading the example.