Voice Control Using Mac OS X and Arduino

4.9K229

Intro: Voice Control Using Mac OS X and Arduino

In this Inscrutable we are going to add voice control to Arduino using MAC OS X inbuilt feature of accessibilty and Voice recognition.

Here is the link of working System.

Led's are on table, Sorry for so reduced visibility of LED's.

STEP 1: Installing Arduino-Serial Utility

Download Arduino Serial Utility and Extract it in your home folder.

Use command in terminal:

make arduino-serial

List the Serial Ports available using command:

ls /dev/tty.*

Copy the port on which Arduino is connected

STEP 2: Connections on Arduino

Connect a Green led on Arduino on 11 pin.

and Burn following code to Arduino

int Green = 11;

void setup()

{

pinMode(Green,OUTPUT); // declare the LED's pin as output

Serial.begin(9600); // connect to the serial port

}

void loop () {
val = Serial.read(); // read the serial port

if(val == '2')

{ digitalWrite(Green,HIGH);

}

if(val == '5')

{ digitalWrite(Green,LOW);

}

}

STEP 3: Create a Application Using Automator

Go to automator

Select to create a new application

Select Run a shell Script on left hand side.

and write these commands to the shell script.

While Writing these command do replace serial port names by yours which are copied in the first step.

The first command is to communicate using USB port.

and the second command is to communicate via Bluetooth Port.

Save it to applications folder.

For more detail on the commands refer this arduino-serial link.

STEP 4: Create a Command in Accessibility.

Go to dictation comands and create a new command as shown.

If Dictation is not available then you will have to download offline recognition. by checking the box of use enhanced dictation in Dictation and Speech Preferences.

Add Your command in What is say box.

and choose application to run on that command.

STEP 5: Connect Arduino Via USB or Bluetooth.

For bluetooth just connect Rx of bluetooth pin to Tx pin on Arduino and Tx of Bluetooth to Rx of Arduino.

And VCC of bluetooth to 5V of Arduino and GNG To Any GND on Arduino.

Now pair your bluetooth in settings.

I pairing fails then you will have to check password of your bluetooth in advanced settings.

For USB just plugin Your Arduino.

STEP 6: Running Voice Recognition.

For Accessibility short cut.

By default we need to press fn key twice.

A listening mic will appear as shown now say your command.

And bingo if every thing is right than it will Turn the Green led On.

9 Comments

Hi Rajat,

I'm trying to get your tutorial to work but for some reason when I run my script and then run my Arduino code, it doesn't pass the correct value to val. I don't know where it gets -1, but that's what it prints in the serial monitor. Any ideas? Thank you so much!

I should add that I've tried both .tty and .cu as the port in my Automator script. I'm very new to Arduino and Automator by the way!

So what change do you make to the C++ code to turn the LED light off?

Actually I understand the on/off using the commands. I'm struggling working individual lights without uploading a different program

Nice! Do you also know how to use the -r function? I would like to send and receive data from my arduino and display it in a mac app.

Go to arduino-serial link in third step, there you will get detailed Guideline.

./arduino-serial -b 9600 -p /dev/cu.usbserial -r

This will get serial data from arduino to your terminal.