If you loved the video and the content on my channel consider helping support the channel at my Patreon below: https://www.patreon.com/LeMasterTech
Don't forget to leave a like on the video, subscribe to channel and let me know in the comments below what you'd like to see next!! Thanks for watching - see you next time!
what's going on you guys welcome back to
the channel and in this video I'm going
to show you how to use voice recognition
with an Arduino hello
robot all on light
cycle light one off light two off light
one on Turn Off the
[Music]
Lights now at the core of this project
obviously is the voice recognition
module and there are so many different
modules with so many Variations by so
many vendors out there that it's best to
do a project like this where you define
your actual needs from the module and
then start looking for a module that can
do that for me I want a module that
wouldn't rely on an internet PC or cloud
service connection wouldn't need to call
an external API and so I was looking for
a completely offline voice recognition
module that would be capable of setting
custom command words and that's how I
found the DF robot gravity offline voice
recognition module so far I love this
thing it's been crazy easy to use and I
will leave a link to it below it can
communicate over i2c or U which if you
don't know what that means just
basically means it'll be compatible with
any microcontroller Raspberry Pi PC any
app that you probably want to use to
talk to this thing this will support u
in particular is basically using two
digital pins on an Arduino as if they
were a serial connection very similar to
what we did with the Bluetooth module on
this channel a few videos back and the
whole wiring for this module just
requires 5 volts DC a ground connection
and then two digital pin connections to
simulate your soft serial connection and
the crazy part about this module which I
love is you do a lot of the actual
programming for your application just by
using your voice and talking to the
module so let's do some of that now
let's start by deleting out anything
that might already be in there so you
guys know I'm doing it live with you the
default way to wake this thing up as
soon as it's powered on is just by
saying hello robot yes I'm here and then
if you want to clear it all out make
sure you're starting fresh just say I
want to delete do you want to delete the
Learned wake word or command word and if
you want to clear it all you just say
delete
all deleting successful okay so first
thing we'll do here is I don't really
like having to say hello robot every
time I want to talk to it so let's pick
a name for it uh maybe you want to rip
off one of the most common uh smart
voice applications or maybe you want
something custom I don't want to give
too much away about what's coming on the
channel but I'm going to do some pretty
cool stuff in my garage workshop with
this so I'll call mine Gary short for
garage electronic assistant hello robot
how can I help learn wake word learning
now be quiet please say the Wake word to
to be learned Gary learning successful
please say it again Gary learning
successful please say it again Gary okay
learning completed so now once it goes
to sleep and the blue light on it goes
away I should be able to use that call
word to wake it up instead of having to
say the original one so when the blue
light goes away it's no longer listening
and we can check and see if it took Gary
yes I'm here and then the blue light
comes back on so that is super easy to
just change your wake word right there
and again if any of the specific things
you need to say to it ever get confusing
just know that their website has
extensive documentation on all of the
command words how to set all of this how
to reset all of it all of the fixed
command words and all of the custom
command words so for example there are
121 commands built into it that you
can't change and you're not going to use
most of those like set to specific
colors or daylight mode Moonlight mode
color mode you can use those if you want
in your program and we'll talk about how
in the next section but there are 17
customizable commands which are where
you get to set up whatever specific
thing you want to say to the module so
for my sample project here I have three
LEDs a blue red and green LED and I just
want to create custom commands that will
let me turn them all on in a sequence
all off off and then each of them
individually on and off and then also
some sort of fun like light show light
cycle at the end so let's take a look at
how quick and easy to set custom
commands on this it is as well Ary yes
I'm here learning command word learning
now be quiet please learn the command
word according to the prompt please say
the first command to be learned all on
learning successful please say it again
again all on learning successful please
say it again all on okay learn the First
Command successfully please say the
second command to be
learned
hold light one on light one on light one
on light one off light one off light one
off light two on light two on light two
on light three on light three on light
three
on light two off light two off light two
off light three off light three off
light three
off light ccle
light it again light
cycle okay learn the
commande say the 10 command to be
learned exit learning okay the learning
mode is exited okay so even if that
seemed a little tedious having to repeat
each command three times it was still
super easy to do just a little bit time
consuming and honestly the fact that you
can do that level of customization and
programming from a $20 module this size
is absolutely nuts and we need to take a
look at how to use those commands we
just created to do things with our
aduino and so we're about to jump into
the coding but I want to touch on a few
features of the module that I forgot to
bring up right in the beginning there's
a dip switch to specify whether you're
communicating over U or i2c
Communications and there's a second dip
switch here which allows you to switch
between speaker 1 and speaker 2 and
speaker one is the builtin speaker that
comes with the module but if you want a
real highquality output you can hook it
up to an external speaker and that's
what switch uh speaker 2 will do if you
flip the dip switch into that position
it's also kind of nice if you want to be
able to give your board commands and you
don't want to hear the voice back at all
you can put this into speaker 2 position
and just not hook an external speaker up
and then you can give it commands and
you just won't get any audio feedback so
if you don't like the voice you just
want to be able to give it VI uh audio
commands and not have it talk back to
you at all then you can flip it into
speaker 2 and just not hook up an
external speaker it'll still work now
the biggest reason I'm not going to have
a line by line coding along section in
this project is the vast majority of the
code required to make this run the way
you want it to run is coming from an
example provided by the vendor and this
is true of most vendors who make Arduino
compatible or any like hobby electronics
compatible modules they create libraries
and Sample code on how to use their
module so you just need to tweak it for
your custom application so in my case
they had sample code on their website of
how to control an LED I added two more
LEDs to it um and then I added a whole
bunch of custom commands and that's the
part we really need to talk about so if
you go to their website which I'll link
below or you grab the code from my
GitHub which will also be linked below
then the sample code you'll see will
already have bringing in the library
detecting what form of communication
it's most likely using based on the
board that you're using and then just
make sure in your setup code that
whatever devices you have you initialize
those pins like you would with any other
Arduino project but it takes care of the
serial. begin and then it has some
specific code for the ASR or sound
recognition module um to begin and it's
best to just leave that alone while
you're testing you can start tweaking
that and changing some of the initial
parameters once the basics are working
but their sample code and the code I
have in the GitHub is going to work fine
to get you up and running the code that
we need to focus on on the custom
commands and how to use the audio input
in our Arduino project is happening in
the loop section of our code and
basically no matter what the uh voice
command that comes back or if no valid
command was received at all it gets
stored in this integer value CMD ID
command ID and all we have to do is an
elaborate switch case uh bunch of code
to detect what command ID was just
issued and perform actions accordingly
and like I said earlier it comes with
121 pre-built commands and by looking at
their documentation I can see that if I
say turn on the light that's going to be
pre-built command ID 103 and if I say
turn off the light that's command ID 104
so the first two rungs I'll put in my
code are the case 103 Turn All the
Lights On case 104 Turn All the Lights
Off I'll use that to be very plain and
general code now next and again you just
get this from their documentation I can
see that case five is going to be the
first case where I set a custom command
so if you remember when I was setting
them the first one I said was all on and
I'm going to have this be a little
different than just turn on the light
which is the pre-built command and I'm
going to have them do this in sequence
so I'll flip all my lights off and then
in sequence I'll have them start up and
then for all off I'll basically have it
do uh the same but in Reverse turn them
all on and then in sequence turn them
off and that'll be case six and for case
seven that's going to be turned just the
blue light on case8 turn just the blue
light off case nine and 10 same for
turning on and off the red light and
then 11 and 12 will be the same for the
green light and then case 13 where I
said it was going to be a light cycle
I'm just going to program all of the
lights to turn on in a progressively uh
slower cycle so I'll have it like
initially really fast and then it'll
slow down just for fun to Showcase that
we can do things like that using Arduino
programming and then the pre-built
default section is just if the command
ID is not equal to zero just print what
the command ID is equal to so that you
can monitor it in a Serial
window and that's really all it takes go
ahead and verify it make sure you don't
have any errors again if you are doing a
custom application you might consider
building a board like this to make sure
that your module is under uh is working
and you get the basics before you build
something elaborate and hook it all up
expecting it to work I think it's super
easy to use but it's still important to
get the fundamentals of what you're
doing down before you try to do
something
crazy or you can mess around and find
out it's up to you all right let's test
every one of those cases we just made
and make sure they all work hey Gary how
can I help turn on the light okay turn
off the light okay all on okay all off
okay turn on light one light light two
on light three on light one off light
two off light three off light
cycle okay you guys that is going to do
it for this video on introduction to
voice recognition using Arduino a
massive thank you to DF robot I reached
out to them let them know I wanted to do
this project they were super
enthusiastic and sent me the module so
thank you to them be sure to check out
their full catalog not just this sensor
they have a ton of great Arduino and
home electronics projects be sure to
check them out there'll be a link to
their full online website and Catal log
in the description as well as this
specific sensor as well as a GitHub with
all of the code that I used in this
video um and the DF robot sample code
thank you so much for watching I can't
believe we're almost at 10K subscribers
on the channel that is amazing massive
thank you to patreon supporters Dale and
Phillip as always thank you to everyone
who watches my videos leaves likes and
nice comments until next time good luck
with your projects good luck coding
thanks
bye