Movi and RGB

Hello,

I want my Movi Shield to control a common cathode RGB LED. The problem is when I upload the code it doesn’t work. I don’t get a response from the Movi Shield and it doesn’t execute any commands. However if I upload the earlier version of the code (V.2) it works perfectly.

How do I get this to work?

Thanks in advance.

(Also, for some reason the LCD screen will only display when the Movi shield is powered and the Arduino Mega is plugged into the computer. It won’t display when just the Movi is powered. (It should have enough power because it is being powered by a 9v 2a power supply) Does anyone know how to fix that problem as well? Thanks.)

// B.A.X.T.E.R C.C.H A.I Code
// V.3 
// 04/03/2021
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#include "MOVIShield.h" // Include MOVI library, needs to be *before* the next #include

#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_PIC32)
#include <SoftwareSerial.h> // This is nice and flexible but only supported on AVR and PIC32 
architecture, other boards need to use Serial1 
#endif


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

//MOVI Uses Pins 10 & 11 to Communicate With the Arduino.To rewire MOVI’s communication to 
different pins, open Jumper 2 and Jumper 3 and connect the right side of MOVI's TX jumper 
(Jumper 2) 
//and the right side of MOVI's RX jumper (Jumper 3) to two other connectors on the Arduino 
headers using jumper wires. The right side is the pin that is closer to the power and USB plugs.
int Contrast=45;
LiquidCrystal lcd(12, 9, 5, 4, 3, 7);  

//RGB LED (Common Cathode)
const int redpin = 8;
const int greenpin = 10;
const int bluepin = 11; 

//Millis-Link: https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of- 
delay/
int period = 10000; //10 Sec Delay
unsigned long time_now = 0;


void setup()  
{
 recognizer.init(); // Initialize MOVI (waits for it to boot)

  //*
  // Note: training can only be performed in setup(). 
  // The training functions are "lazy" and only do something if there are changes. 
 // They can be commented out to save memory and startup time once training has been 
 performed.
 recognizer.callSign("Baxter"); // Train callsign Arduino (may take 20 seconds)
  recognizer.addSentence(F("Turn on")); //1
  recognizer.addSentence(F("Go Dark")); //2
  recognizer.addSentence(F("Run system check")); //3
  recognizer.addSentence(F("Goodbye")); //4
  recognizer.addSentence(F("Are you a robot")); //5
  recognizer.addSentence(F("Are you evil?")); //6 
  recognizer.train();// Train (may take 20seconds) 
  //*/

  //  recognizer.setThreshold(5);      // uncomment and set to a higher value (valid range 2-95) if 
you have a problems due to a noisy environment.

//Define
//RGB LED
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);
//LCD Screen 
 analogWrite(6,Contrast);
     lcd.begin(16,2); 
}

void loop() // run over and over
{
   signed int res=recognizer.poll(); // Get result from MOVI, 0 denotes nothing happened, negative 
values denote events (see docs)

 if (res == 1)
 {
   recognizer.say("Hello commander. How may I be of service?");
   //Activate Green
   digitalWrite(greenpin, HIGH);
   digitalWrite(bluepin, LOW); 
   digitalWrite(redpin, LOW);  
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("I AM");
   lcd.setCursor(0,1);
   lcd.print("B.A.X.T.E.R");
        recognizer.ask();   
   }

   if (res == 2) {
  recognizer.say("Goodnight commander"); 
   //Turn off RGB LED
   digitalWrite(redpin,LOW); 
   digitalWrite(greenpin,LOW);
   digitalWrite(bluepin,LOW); 
   //Display on screen then vanish
   time_now=millis();
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Night Night");
   lcd.setCursor(0,1);
   lcd.print("ZZZZ...");
   while(millis()<time_now+period){
   //wait approx. [period] ms
   }
  lcd.clear();
  }

   if (res == 3) {
   recognizer.say("Systems operating at full capacity");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("At Least I");
   lcd.setCursor(0,1);
   lcd.print("Think They Are");
  }

  if (res ==4) {
    recognizer.say("Finally, I can enjoy some peace and quiet");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Ahh...Peace");
   lcd.setCursor(0,1);
   lcd.print("At Last");
  }

  if (res ==5) {
    recognizer.say("Pish posh! I am an artificial intelligence system");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("How Dare You!");
   lcd.setCursor(0,1);
   lcd.print("I Am an A.I!");
  }

  if (res ==6) {
    recognizer.say("This is your last chance to leave a tip!"); //X-Files Easter Egg 
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("X-Files");
   lcd.setCursor(0,1);
  lcd.print("Reference");
  }

 } 

THE OLDER VERSION (That works)

// V.2
// 11/7/2020
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#include "MOVIShield.h" // Include MOVI library, needs to be *before* the next #include

#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_PIC32)
#include <SoftwareSerial.h> // This is nice and flexible but only supported on AVR and PIC32 
architecture, other boards need to use Serial1 
#endif


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

//MOVI Uses Pins 10 & 11 to Communicate With the Arduino. To rewire MOVI’s communication to 
different pins, open Jumper 2 and Jumper 3 and connect the right side of MOVI's TX jumper 
(Jumper 2) 
//and the right side of MOVI's RX jumper (Jumper 3) to two other connectors on the Arduino 
headers using jumper wires. The right side is the pin that is closer to the power and USB plugs.
int Contrast=45;
LiquidCrystal lcd(12, 9, 5, 4, 3, 7);  

 const int EYE_RELAY_PIN = 2;  // the Arduino pin, which connects to the IN pin of relay

//Millis-Link: https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of- 
delay/
int period = 10000; //10 Sec Delay
unsigned long time_now = 0;


void setup()  
{
  recognizer.init(); // Initialize MOVI (waits for it to boot)

   //*
   // Note: training can only be performed in setup(). 
   // The training functions are "lazy" and only do something if there are changes. 
   // They can be commented out to save memory and startup time once training has been 
performed.
  recognizer.callSign("Baxter"); // Train callsign Arduino (may take 20 seconds)
  recognizer.addSentence(F("Turn on")); //1
  recognizer.addSentence(F("Go Dark")); //2
  recognizer.addSentence(F("Run system check")); //3
  recognizer.addSentence(F("Goodbye")); //4
  recognizer.addSentence(F("Are you a robot")); //5
  recognizer.addSentence(F("Are you evil?")); //6 
  recognizer.train();// Train (may take 20seconds) 
  //*/

  //  recognizer.setThreshold(5);      // uncomment and set to a higher value (valid range 2-95) if 
you have a problems due to a noisy environment.

//Define 
pinMode(EYE_RELAY_PIN, OUTPUT); //We will be using the N.C of the Relay
 analogWrite(6,Contrast);
     lcd.begin(16,2); 
}

void loop() // run over and over
{
  signed int res=recognizer.poll(); // Get result from MOVI, 0 denotes nothing happened, negative 
values denote events (see docs)
 if (res == 1) 
 {
    recognizer.say("Hello commander. How may I be of service?");
        digitalWrite(EYE_RELAY_PIN, LOW); //Turns on Eye (N.C)
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("I AM");
   lcd.setCursor(0,1);
   lcd.print("B.A.X.T.E.R");
        recognizer.ask();   
  }
  if (res == 2) {
    recognizer.say("Goodnight commander"); 
     digitalWrite(EYE_RELAY_PIN, HIGH); //Turns off Eye (N.C)
   time_now=millis();
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Night Night");
   lcd.setCursor(0,1);
   lcd.print("ZZZZ...");
   while(millis()<time_now+period){
   //wait approx. [period] ms
   }
  lcd.clear();
  }
  if (res == 3) {
    recognizer.say("Systems operating at full capacity");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("At Least I");
   lcd.setCursor(0,1);
   lcd.print("Think They Are");
  }
  if (res ==4) {
    recognizer.say("Finally, I can enjoy some peace and quiet");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Ahh...Peace");
   lcd.setCursor(0,1);
   lcd.print("At Last");
  }
  if (res ==5) {
    recognizer.say("Pish posh! I am an artificial intelligence system created by Paglia Industries");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("How Dare You!");
   lcd.setCursor(0,1);
   lcd.print("I Am an A.I!");
  }
  if (res ==6) {
   recognizer.say("This is your last chance to leave a tip!"); //X-Files Easter Egg 
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("X-Files");
   lcd.setCursor(0,1);
   lcd.print("Reference");
  }
}

I ALSO TRIED THIS

// V.3 
// 04/03/2021
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#include "MOVIShield.h" // Include MOVI library, needs to be *before* the next #include

#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_PIC32)
#include <SoftwareSerial.h> // This is nice and flexible but only supported on AVR and PIC32 
architecture, other boards need to use Serial1 
#endif


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

//MOVI Uses Pins 10 & 11 to Communicate With the Arduino.To rewire MOVI’s communication to 
different pins, open Jumper 2 and Jumper 3 and connect the right side of MOVI's TX jumper 
(Jumper 2) 
//and the right side of MOVI's RX jumper (Jumper 3) to two other connectors on the Arduino 
headers using jumper wires. The right side is the pin that is closer to the power and USB plugs.
int Contrast=45;
LiquidCrystal lcd(12, 9, 5, 4, 3, 7);  

//RGB LED (Common Cathode)
const int redpin = 8;
const int greenpin = 10;
const int bluepin = 11; 

//Millis-Link: https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of- 
   delay/
    int period = 10000; //10 Sec Delay
    unsigned long time_now = 0;


void setup()  
{
  recognizer.init(); // Initialize MOVI (waits for it to boot)

  //*
  // Note: training can only be performed in setup(). 
  // The training functions are "lazy" and only do something if there are changes. 
  // They can be commented out to save memory and startup time once training has been 
performed.
  recognizer.callSign("Baxter"); // Train callsign Arduino (may take 20 seconds)
  recognizer.addSentence(F("Turn on")); //1
  recognizer.addSentence(F("Go Dark")); //2
  recognizer.addSentence(F("Run system check")); //3
  recognizer.addSentence(F("Goodbye")); //4
  recognizer.addSentence(F("Are you a robot")); //5
  recognizer.addSentence(F("Are you evil?")); //6 
  recognizer.train();// Train (may take 20seconds) 
  //*/

  //  recognizer.setThreshold(5);      // uncomment and set to a higher value (valid range 2-95) if 
 you have a problems due to a noisy environment.

//Define
//RGB LED
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);
 //LCD Screen 
  analogWrite(6,Contrast);
      lcd.begin(16,2); 
  }

 void loop() // run over and over
 {
   signed int res=recognizer.poll(); // Get result from MOVI, 0 denotes nothing happened, negative 
 values denote events (see docs)

  if (res == 1)
  {
   recognizer.say("Hello commander. How may I be of service?");
   setColor(0, 255, 0);  // green
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("I AM");
   lcd.setCursor(0,1);
   lcd.print("B.A.X.T.E.R");
         recognizer.ask();   
  }

  if (res == 2) {
    recognizer.say("Goodnight commander"); 
   //Turn off RGB LED
setColor(0, 0, 0); 
   //Display on screen then vanish
   time_now=millis();
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Night Night");
   lcd.setCursor(0,1);
   lcd.print("ZZZZ...");
   while(millis()<time_now+period){
   //wait approx. [period] ms
   }
  lcd.clear();
  }

  if (res == 3) {
    recognizer.say("Systems operating at full capacity");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("At Least I");
   lcd.setCursor(0,1);
   lcd.print("Think They Are");
  }

  if (res ==4) {
    recognizer.say("Finally, I can enjoy some peace and quiet");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Ahh...Peace");
   lcd.setCursor(0,1);
   lcd.print("At Last");
   }

  if (res ==5) {
     recognizer.say("Pish posh! I am an artificial intelligence system");
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("How Dare You!");
   lcd.setCursor(0,1);
   lcd.print("I Am an A.I!");
  }

  if (res ==6) {
    recognizer.say("This is your last chance to leave a tip!"); //X-Files Easter Egg 
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("X-Files");
   lcd.setCursor(0,1);
   lcd.print("Reference");
  }

  }

 void setColor (int red, int green, int blue)
{
  analogWrite(redpin, red);
  analogWrite(greenpin, green);
  analogWrite(bluepin, blue);   
}

Nevermind. I got it to work. I just used different pins for the RGB LED (I forgot that the Movi Shield uses pins 10 and 11 to communicate with the Arduino), and I got the LCD display to work as well.

1 Like