Rohan Barnwal
Published

Upgrade Your Car with Voice Commands!

Turn any car into a smart vehicle with voice-controlled infotainment using Arduino Leonardo & DFRobot DF2301Q-hands-free, futuristic

IntermediateFull instructions provided1 hour427
Upgrade Your Car with Voice Commands!

Things used in this project

Story

Read more

Schematics

Connections

Code

Arduino Code

Arduino
#include "DFRobot_DF2301Q.h"
#include "Keyboard.h"  // HID keyboard functionality 

DFRobot_DF2301Q_I2C DF2301Q;

void setup()
{
  Serial.begin(115200);
  Keyboard.begin();  // Initialize Keyboard functionality

  while (!(DF2301Q.begin()))
  {
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }
  Serial.println("Begin ok!");

  DF2301Q.setVolume(6);
  DF2301Q.setMuteMode(0);
  DF2301Q.setWakeTime(15);

  Serial.print("WakeTime = ");
  Serial.println(DF2301Q.getWakeTime());
}

void loop()
{
  uint8_t CMDID = DF2301Q.getCMDID();
  if (CMDID != 0)
  {
    Serial.print("CMDID = ");
    Serial.println(CMDID);

    switch (CMDID)
    {
      case 5:  
        Serial.println("Performing: Windows + M");
        Keyboard.press(KEY_LEFT_GUI);  // Windows key
        Keyboard.press('m');
        delay(100);
        Keyboard.releaseAll();
        break;

      case 6:  
        Serial.println("Performing: Escape");
        Keyboard.press(KEY_ESC);
        delay(100);
        Keyboard.releaseAll();
        break;

      case 7:  
        Serial.println("Performing: Windows + [");
        Keyboard.press(KEY_LEFT_GUI);
        Keyboard.press('[');
        delay(100);
        Keyboard.releaseAll();
        break;

      case 8:  
        Serial.println("Performing: Windows + B");
        Keyboard.press(KEY_LEFT_GUI);
        Keyboard.press('b');
        delay(100);
        Keyboard.releaseAll();
        break;

      case 9:  
        Serial.println("Performing: Windows + N");
        Keyboard.press(KEY_LEFT_GUI);
        Keyboard.press('n');
        delay(100);
        Keyboard.releaseAll();
        break;

      default:
        Serial.println("Unknown CMDID");
        break;
    }
  }
  delay(300);
}

Credits

Rohan Barnwal
23 projects • 34 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!
Contact

Comments

Please log in or sign up to comment.