/*! * @file TM6605_breathe.ino * @brief Slow smooth breathing haptic effect — Seeed XIAO ESP32-S3 * SDA → GPIO5 | SCL → GPIO6 */ #include #include "DFRobot_TM6605.h" DFRobot_TM6605 TM6605; // Play an effect and wait for it to finish before continuing void playEffect(DFRobot_TM6605::eEffect_t effect, int duration) { TM6605.selectEffect(effect); TM6605.play(); delay(duration); TM6605.stop(); delay(50); // small gap between chained effects } void setup() { Serial.begin(115200); while (!Serial); Wire.begin(5, 6); // SDA = GPIO5, SCL = GPIO6 Serial.print("TM6605 init..."); while (TM6605.begin() != 0) { Serial.println("failed, not found!"); delay(1000); } Serial.println("success"); } void loop() { Serial.println("Breathe in..."); // Start soft, build to full playEffect(DFRobot_TM6605::eShortSlowBoostTransition2, 800); playEffect(DFRobot_TM6605::eMediumSlowBoostTransition2, 1000); playEffect(DFRobot_TM6605::eLongSlowBoostTransition1, 1500); // Hold at peak delay(300); Serial.println("Breathe out..."); // Full, taper to soft playEffect(DFRobot_TM6605::eLongSlowFadeTransition1, 1500); playEffect(DFRobot_TM6605::eMediumSlowFadeTransition2, 1000); playEffect(DFRobot_TM6605::eShortSlowFadeTransition2, 800); // Pause at the bottom — adjust this for breath rate delay(600); }