MOVI with Relay

Hello,

I was wondering how I can program the movi shield (using the code format below) to send power to PWM pins when I say a command. I will be using this concept to power relays as described in my example below.

For example:
When I say: "Code red"
I want the Movi Shield to send power to pin 10 so I can activated a relay. The relay will then act as a switch and send power to another ardunio and that ardunio will execute its code.
When I say "At ease"
I want the Movi shield to send power to pin 10 and deactivate the relay.

(I will be using a: Keyestudio Single 5V Relay Module Compatible with Arduino UNO R3 MEGA)

Thanks in advance.

The Movi shield code format I use:

#include

MOVI recognizer (true); //Get a MOVI object, true enables serial monitor interface, rx and tx for alternate communication pins on AVR architecture boards

void setup() {
recognizer.init();
recognizer.callSign(F(“Baxter”)); //Train callsign (may take 20 seconds)
recognizer.addSentence(F(“How are you”)); //1
recognizer.addSentence(F(“Who are you”)); //2
recognizer.addSentence(F(“Run system check”)); //3
recognizer.addSentence(F(“Goodbye”)); //4
recognizer.addSentence(F(“Are you a robot”)); //5
recognizer.addSentence(F(“Run diagnostics”)); //6 (Be sure to update the response every time)
recognizer.train();

}

void loop() {
int res = recognizer.poll();

if (res == 1) {
recognizer.say(“I am doing just well”);
recognizer.ask();
}
if (res == 2) {
recognizer.say(“I am a Life Model Decoy created by Paglia Industries on August 13 2018”);
}
if (res == 3) {
recognizer.say(“Systems operating at full capacity”);
}
if (res ==4) {
recognizer.say(“Goodbye”);
}
if (res ==5) {
recognizer.say(“Pish posh”);
}
if (res ==6) {
recognizer.say(“There is 67% of program storage space and 70% of dynamic memory avaliable”);
}
}

I see 3 needs for your arduino sketch. First you need to define the relay and what pin on the ardurion you are using to power the relay on and off.
For example at th start of your sketch:
const int relay = 13; // the relay is now set to be powered on and off by pin 13

Secondly you need to add to your recognizer sentences “Code Red” and “AT ease”.

Thirdly you need to add a command once the recognizer has discovered your sentence.
I would use the digitalWrite command in your case if the relay is a DC relay.

For example if the “Code Red” was listed as res=7 you would write:
if (res==7) {
digitalWrite(relay, HIGH); // turns on the relay
recognizer.say(“Code Red”); // verbal confirmation the relay is now on
}
if (res==8) {
digitalWrite(relay, LOW); // turns off the relay
recognizer.say(“At ease”); // verbal confirmation the relay is off.
}