Store code somewhere and call it when needed

Hello,

I'm working on a custom A.I using a Movi Shield. I'm adding a lot of commands and although I haven't yet run out of storage/memory space on my Arduino Mega, I'm wondering if I could store portions of my A.I's code on another Arduino Mega so I don't have to worry about running out of room any time soon.

For example, I can ask my A.I to tell me a joke, and it will choose from a list of jokes.

//Jokes
  void Jokes(){
  char *jokes[]={
  "I'm afraid for the calendar. It's days are numbered",
  "My wife said I should do lunges to stay in shape. That would be a big step forward",
  "Why do fathers take an extra pair of socks when they go golfing? In case they get a hole in one",  
  "Singing in the shower is fun until you get soap in your mouth. Then it's a soap opera",  
  "I only know 25 letters of the alphabet. I don't know y", 
  "What does a sprinter eat before a race? Nothing, they fast"
    };
  long jokes1;
    jokes1 = random(sizeof(jokes)/sizeof(char*)); //Randomly says a joke
    recognizer.say((jokes[jokes1])); //Say joke 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 4 sec
   time_now=millis();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off
  }

The problem is, the more jokes I add, the more space I use. I want to add more jokes but I want to store them somewhere else and call them when needed. I would like to do this for most of my subroutines and my A.I's responses.

I already have both of my Arduino Mega's hooked up to each other, and I'm wondering how to "offload" some of my main code to my second Mega to save room.

So I'm wondering how to do this, if this will save me storage & memory space, and if the code will still run well?

Thanks in advance.

Here is my A.I's code so far:

#include <LiquidCrystal.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.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 Serial 
#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.

//PINS 10 & 11 ARE OFF LIMITS. DO NOT CONNECT ANYTHING TO THEM OR THE MOVI WON'T RESPOND OR EXECUTE ANY COMMANDS. 

//Define Connected Pins and Millis Delays
//LCD Screen
int Contrast=5;
LiquidCrystal lcd(12, 9, 5, 4, 3, 7);

//OLED
#define OLED_WIDTH 128
#define OLED_HEIGHT 64
#define OLED_ADDR   0x3C //OLED Address For Display Across Screens 
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);

//Slave Arduino I2C Adress (https://dronebotworkshop.com/i2c-arduino-arduino/)
#define SLAVE_ADDR 9

//Random Stuff (Literally) 
long randNumber;
char *RPS[]={"Rock","Paper","Scissors"};
long RPS1;

//RGB LED
const int redpin=22;
const int greenpin=23;
const int bluepin=2;

//Arduino Pins for triggering RPI SoundFX 
const int Button1=24; //Goes Through Level Shifter to GPIO 4
const int Button2=25; //Goes Through Level Shifter to GPIO 27
const int Button3=26; //Goes Through Level Shifter to GPIO 22
const int Button4=27; //Goes Through Level Shifter to GPIO 23
const int Button5=28; //Goes Through Level Shifter to GPIO 24
const int Button6=29; //Goes Through Level Shifter to GPIO 25
const int Button7=30; //Goes Through Level Shifter to GPIO 5
const int Button8=31; //Goes Through Level Shifter to GPIO 6
const int Button9=32; //Goes Through Level Shifter to GPIO 12
const int Button10=33; //Goes Through Level Shifter to GPIO 13
const int Button11=34; //Goes Through Level Shifter to GPIO 26
const int Button12=35; //Goes Through Level Shifter to GPIO 17

//Millis-Link: https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of-delay/
int period1 = 1000; //1sec Delay
int period2 = 2000; //2sec Delay
int period3 = 3000; //3sec Delay
int period4 = 4000; //4sec Delay
int period5 = 5000; //5sec Delay
int period6 = 6000; //6sec Delay
int period7 = 7000; //7sec Delay
int period8 = 8000; //8sec Delay
int period9 = 9000; //9sec Delay
int period10 = 10000; //10sec Delay
int period20 = 20000; //20sec 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 (may take 20 seconds)
  recognizer.addSentence(F("Turn on")); //1
  recognizer.addSentence(F("Go Dark")); //2
  recognizer.addSentence(F("Run systems check")); //3
  recognizer.addSentence(F("I'm leaving")); //4
  recognizer.addSentence(F("Who are you")); //5
  recognizer.addSentence(F("Are you evil")); //6
  recognizer.addSentence(F("How are you today")); //7
  recognizer.addSentence(F("I'm back")); //8 
  recognizer.addSentence(F("Sing a Song")); //9 
  recognizer.addSentence(F("Hello")); //10 
  recognizer.addSentence(F("Can you play an instrument")); //11
  recognizer.addSentence(F("Will you marry me")); //12
  recognizer.addSentence(F("Are aliens real")); //13
  recognizer.addSentence(F("Quote a movie")); //14
  recognizer.addSentence(F("I don't understand")); //15
  recognizer.addSentence(F("I forgot what I was going to say")); //16
  recognizer.addSentence(F("No")); //17
  recognizer.addSentence(F("Mute")); //18
  recognizer.addSentence(F("Unmute")); //19
  recognizer.addSentence(F("Pick a number")); //20
  recognizer.addSentence(F("Rock Paper Scissors")); //21
  recognizer.addSentence(F("Tell a joke")); //22
  recognizer.addSentence(F("Roll a dice")); //23
  recognizer.train();// Train (may take 20seconds) 
  //*/

//Say a welcome message
recognizer.say("I am ready, commander. Just call me Baxter");
SplashScreen();

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

  //Define All Modules Connected 

//LCD
 analogWrite(6,Contrast);
     lcd.begin(16,2);

//Random Number
randomSeed(analogRead(0));
          
//RGB LED
pinMode(redpin,OUTPUT);
pinMode(greenpin,OUTPUT);
pinMode(bluepin,OUTPUT);

//Virtual Buttons
pinMode(Button1,OUTPUT);
pinMode(Button2,OUTPUT);
pinMode(Button3,OUTPUT);
pinMode(Button4,OUTPUT);
pinMode(Button5,OUTPUT);
pinMode(Button6,OUTPUT);
pinMode(Button7,OUTPUT);
pinMode(Button8,OUTPUT);
pinMode(Button9,OUTPUT);
pinMode(Button10,OUTPUT);
pinMode(Button11,OUTPUT);
pinMode(Button12,OUTPUT);

//Initialize I2C Communications as Master
Wire.begin();
  
}

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)

//Turn RGB Led on to let us know you're listening & turn it off when done listening.  
   if (res==BEGIN_LISTEN) { // This is returned at the start of listening
       RGB_color(0, 255, 0); //Green    
  }
  if (res==END_LISTEN) { // This is returned at the end of listening
     RGB_color(0, 0, 0); //Off 
  }

  //Reponses & Command Executions 

//Command 1
 if (res == 1) 
 {
    recognizer.say("Hello commander. How may I be of service?");
   RGB_color(0, 255, 0); //Green    
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("I AM");
   display.setCursor(0,17);
   display.print("BAXTER");
   display.display();
        recognizer.ask();   
  }

//Command 2
  if (res == 2) {
    recognizer.say("Goodnight commander"); 
     RGB_color(0, 0, 0); //Off
   //Display then turn off after 10 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Good Night");
   display.setCursor(0,17);
   display.print("ZZZZ");
   display.display();
   while(millis()<time_now+period10){
   //wait approx. 10sec
   }
  ClearDisplay(); //Calls Clear Display Subroutine. 
  }

//Command 3
  if (res == 3) {
    RGB_color(255, 255, 0); //Yellow
    SystemCheck(); //Calls System Check Subroutine
    recognizer.say("Systems operating at full capacity");
   //Display then turn off after 5 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("At Least");
   display.setCursor(0,17);
   display.println("I Think");
   display.println("They");
   display.println("Are");
   display.display();
      while(millis()<time_now+period3){
   //wait approx 3sec
   }
  SplashScreen(); //Calls Splash Screen Subroutine
  recognizer.say("Is there anything else you'd like me to do?");
  recognizer.ask(); 
  }

//Command 4
  if (res ==4) {
    recognizer.say("Finally, I can enjoy some peace and quiet");
   //Display then turn off after 5 sec
   time_now=millis();
   RGB_color(255, 255, 255); //White
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Ahh..Peace");
   display.setCursor(0,17);
   display.print("At Last");
   display.display();
      while(millis()<time_now+period5){
   //wait approx. 5sec
   }
  RGB_color(0, 0, 0); //RGB LED Off 
  SplashScreen(); //Call SplashScreen
  }

//Command 5
  if (res ==5) {
    recognizer.say("I am Baxter, an artificial intelligence system");
   RGB_color(255, 255, 255); //White
   //Display then turn off after 6 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("How Dare");
   display.setCursor(0,17);
   display.println("You");
   display.println("Question");
   display.println("Me");
   display.display();
      while(millis()<time_now+period6){
   //wait approx. 6sec
   }
  RGB_color(0, 0, 0); //RGB LED Off 
  SplashScreen(); //Call SplashScreen 
  }

//Command 6
  if (res ==6) {
   digitalWrite (Button2, HIGH);
   RGB_color(255, 0, 0); //Red
   //Simulate a 2sec Button press to trigger RPi
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("There Are");
   display.setCursor(0,17);
   display.println("No Strings");
   display.println("On Me");
   display.display();
   while(millis()<time_now+period2){
   //2sec Delay
   //wait approx 2sec to simulate virtual button press
   }
   digitalWrite (Button2, LOW);
   //Keep RGB LED and LCD Display on for 20sec
    while(millis()<time_now+period20){
   //20sec Delay
   //wait approx 20sec for Audio clip to finish
   } 
  RGB_color(0, 0, 0); //RGB LED Off after 20 sec  
  ClearDisplay(); //Clear Display after 20 sec
  }

//Command 7
   if (res ==7) {
    recognizer.say("That is a pointless and rhetorical question. As an artifical intelligence system I have no feeling or emotions, so how could I decipher how I am feeling today."); 
   RGB_color(255, 0, 255); //Magenta
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("I'm Fine");
   display.setCursor(0,17);
   display.println("Thanks For");
   display.println("Asking");
   display.display();
   while(millis()<time_now+period10){
   //wait approx. 10sec
   }
  RGB_color(0, 0, 0); //RGB LED Off 
  SplashScreen(); //Call SplashScreen
  }

//Command 8
  if (res ==8) {
  //Simulate a 2sec Button press to trigger RPi
   RGB_color(0, 0, 255); //Blue
   digitalWrite(Button1, HIGH); 
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("NO!");
   display.setCursor(0,17);
   display.println("PLEASE NO!");
   display.println("NOOOOOO!");
   display.display();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. 2sec
   }
  digitalWrite(Button1,LOW);
  ClearDisplay(); //Clears Display
  RGB_color(0, 0, 0); //Off
  }

//Command 9
  if (res ==9) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button3, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("I Shall");
   display.setCursor(0,17);
   display.println("Serenade");
   display.println("You Now");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button3,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clears Display
  }

//Command 10
  if (res ==10) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button4, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Hello");
   display.setCursor(0,17);
   display.println("Watts Up?");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button4,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clear Display
  }

//Command 11
   if (res ==11) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button5, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("I Can");
   display.setCursor(0,17);
   display.println("Play The");
   display.println("Sax");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button5,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clears Display
  }

//Command 12
   if (res ==12) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button6, HIGH);
   RGB_color(0, 0, 255); //Blue
  display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Uhh...");
   display.setCursor(0,17);
   display.println("No");
   display.println("I'm Good");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button6,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clear Display
  }

//Command 13
   if (res ==13) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button7, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("The Truth");
   display.setCursor(0,17);
   display.println("Is Out");
   display.println("There");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button7,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clear Display
  }

//Command 14
   if (res ==14) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button9, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Your Wish");
   display.setCursor(0,17);
   display.println("Is My");
   display.println("Command");
   display.display(); 
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button9,LOW);
  RGB_color(0, 0, 0); //Turn off RGB After 2sec
  ClearDisplay(); //Clears Display
  }

//Command 15
  if (res ==15) {
  //Simulate a 2sec Button press to trigger RPi
   digitalWrite(Button8, HIGH);
   RGB_color(0, 0, 255); //Blue
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Me Neither");
   display.display();
   time_now=millis();
   while(millis()<time_now+period2){ 
   //Uses period2 (2sec delay) instead of period10 (10sec delay)
   //wait approx. [period] ms
   }
  digitalWrite(Button8,LOW);
  RGB_color(0, 0, 0); //Off
  ClearDisplay(); //Clears Display
  }

//Command 16
    if (res == 16) {
    recognizer.say("Not a problem. Just let me know when your thoughts return. I'll be here waiting as always"); 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 5 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Me Too");
   display.setCursor(0,17);
   display.println("Such A");
   display.println("Shame");
   display.display();
   while(millis()<time_now+period5){
   //wait approx. 5sec
   }
  RGB_color(0, 0, 0); //Off
  SplashScreen(); //Call SplashScreen
  }

//Command 17
    if (res == 17) {
    recognizer.say("Ok"); 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 2 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Ok");
   display.display();
   while(millis()<time_now+period2){
   //wait approx 2sec
   }
  RGB_color(0, 0, 0); //Off
  SplashScreen(); //Calls Splash Screen Subroutine
  }

  //Command 18
    if (res == 18) {
    recognizer.say("Sorry. I will mute myself immediately"); 
    RGB_color(255, 0, 255); //Purple
   //Display then turn off after 2 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("I'm Muted");
   display.setCursor(0,17);
   display.println("Ohh...The");
   display.println("Pain!");
   display.display();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off 
  recognizer.setVolume(0); //Sets Volume to 0
  }

  //Command 19
    if (res == 19) {
    recognizer.setVolume(100); //Sets Volume Back to Default (100)
    recognizer.say("Finally. I was biting my tongue for so long. I think I set a world record."); 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 2 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Finally");
   display.setCursor(0,17);
   display.println("I'm");
   display.println("Unmuted");
   display.display();
   while(millis()<time_now+period2){
   //wait approx 2sec
   }
  RGB_color(0, 0, 0); //Off 
  SplashScreen(); //Calls Splash Screen Subroutine
  }

  //Command 20
    if (res == 20) {
    randNumber = random(50); //Pick a number from 0-50
    recognizer.say("I choose"+String(randNumber)); //Say the chosen number 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 4 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,17);
   display.print("    "+String(randNumber)); //Display Number on OLED
   display.display();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off
  SplashScreen(); //Calls Splash Screen Subroutine
  }

   //Command 21
    if (res == 21) {
    RPS1 = random(sizeof(RPS)/sizeof(char*)); //Randomly Picks Rock Paper or Scissors 
    recognizer.say("I choose"+String(RPS[RPS1])); //Say Choice 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 4 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,17);
   display.print(RPS[RPS1]); //Display choice on OLED
   display.display();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off
  SplashScreen(); //Calls Splash Screen Subroutine
  }
  
   //Command 22
    if (res == 22) {
   Jokes(); //Calls Jokes Subroutine 
  }

  //Command 23
    if (res == 23) {
    randNumber = random(1,6); //Pick a number from 1-6
    recognizer.say("It rolled on"+String(randNumber)); //Say the chosen number 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 4 sec
   time_now=millis();
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,17);
   display.print("    "+String(randNumber)); //Display Number on OLED
   display.display();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off
  SplashScreen(); //Calls Splash Screen Subroutine
  }
  
 }

 //Subroutines 

//RGB
 void RGB_color(int redvalue, int greenvalue, int bluevalue)
 {
  analogWrite(redpin, redvalue);
  analogWrite(greenpin, greenvalue);
  analogWrite(bluepin, bluevalue);
  }

//BAXTER Online Screen - OLED
  void SplashScreen() {
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("BAXTER");
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 17);
  display.println("A.I");
  display.println("System");
  display.println("Online");
  display.display();
  }

//Clear OLED Display
  void ClearDisplay(){
  display.clearDisplay();
  display.display(); 
  } 

//Jokes
  void Jokes(){
  char *jokes[]={
  "I'm afraid for the calendar. It's days are numbered",
  "My wife said I should do lunges to stay in shape. That would be a big step forward",
  "Why do fathers take an extra pair of socks when they go golfing? In case they get a hole in one",  
  "Singing in the shower is fun until you get soap in your mouth. Then it's a soap opera",  
  "I only know 25 letters of the alphabet. I don't know y", 
  "What does a sprinter eat before a race? Nothing, they fast"
    };
  long jokes1;
    jokes1 = random(sizeof(jokes)/sizeof(char*)); //Randomly says a joke
    recognizer.say((jokes[jokes1])); //Say joke 
    RGB_color(255, 255, 255); //White
   //Display then turn off after 4 sec
   time_now=millis();
   while(millis()<time_now+period4){
   //wait approx 4sec
   }
  RGB_color(0, 0, 0); //Off
  }

//Systems Check 
 void SystemCheck()
 {
    displayFunction(0); //Display 0%   
    recognizer.say("Starting Scan");
    delay(2000);
    displayFunction(8); //Display 8% 
    recognizer.say("Checking Essential Colors");
    delay(2000);
    displayFunction(17); //Display 17% 
    recognizer.say("Checking Red"); 
    RGB_color(255, 0, 0); //Red
    delay(3000);
    displayFunction(26); //Display 26% 
    recognizer.say("Checking Green");
    RGB_color(0, 255, 0); //Green
    delay(3000);
    displayFunction(34); //Display 34% 
    recognizer.say("Checking Blue");
    RGB_color(0, 0, 255); //Blue
    delay(3000);
    displayFunction(43); //Display 43% 
    recognizer.say("Color Check Completed");
    RGB_color(255, 255, 0); //Yellow
    delay(2000);
    displayFunction(52); //Display 52% 
    recognizer.say("Checking Non-Essential Colors");
    delay(2000);
    displayFunction(60); //Display 60% 
    recognizer.say("Checking White"); 
    RGB_color(255, 255, 255); //White
    delay(3000);
    displayFunction(69); //Display 69% 
    recognizer.say("Checking Purple");
    RGB_color(255, 0, 255); //Purple
    delay(3000);
    displayFunction(78); //Display 78% 
    recognizer.say("Checking Yellow");
    RGB_color(255, 255, 0); //Yellow
    delay(3000);
    displayFunction(87); //Display 87% 
    recognizer.say("Non-Essential Color Check Complete");
    delay(3000);
    displayFunction(95); //Display 95% 
    recognizer.say("Scanning");
    delay(3000);
    recognizer.say("Displaying System Information");
    SystemInfo();//Call System Info Display
    delay(8000);
    displayFunction(99); //Display 99% 
    recognizer.say("Scanning");
    delay(3000);
    recognizer.say("Scan Complete");
    display.clearDisplay();
    display.setTextSize(2);
    display.setCursor(0,0);
    display.print("Scanning");
    display.setCursor(0,17);
    display.print("Complete");
    display.display();
    delay(3000);
  }

//Percent Display Function
void displayFunction(int percent) {
   display.clearDisplay();
   display.setTextSize(2);
   display.setCursor(0,0);
   display.print("Scanning");
   display.setTextSize(2);
   display.setCursor(0,17);
   display.println("Please");
   display.println("Wait...");
   display.setTextSize(1);
   display.print(percent); 
   display.println(" %");
   display.display();
}

//BAXTER System Info Display (Must Be Manually Updated)
  void SystemInfo() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("System Info:");
  display.setTextSize(1);
  display.setCursor(0, 17);
  display.println("Version: 6.5");
  display.println("Name: BAXTER");
  display.println("Storage Used: 13%");
  display.println("Memory Used: 32%");
  display.display();
  }

I have, in the past, used the EEPROM in a RTC so store a lookup table.

Since I have been using ESP32's, memory has not been an issue.

have you considered storing strings in PROGMEM?

Storing code other than in the program memory would be troublesome.

However, storing strings like your "jokes" is relatively easy:

  1. They could be stored in flash, freeing RAM (RAM is much smaller than flash on most microcontrollers.)
  2. They could be stored on an external EEPROM, FRAM, or Serial Flash chip. There are already libraries that will make this relatively easy. Small chips holding up to about 16MB of data are relatively cheap.
  3. They could be stored on something like an SD card. I'm not sure of the status of the existing libraries WRT today's "typical" 16-32GB SD card size, but you can usually find older cards in the 64M-2GB range that should work fine.

(larger external storage schemes tend to use a "filesystem" to keep the space organized. Just like your PC.)

How would I go about programming that and what's the hardware called that I would need?

I recommend an SD card also, store all you want there, SD cards are 4/8/16/32 Gigabyte, vs the minuscule (in comparison) 256 Megabyte (1/4 Gigabyte) in the Mega2560.

Ok. So I would use something like this, correct?

Yes.
There is no active 5V to 3.3V level conversion, and 3.3V to 5V.
There are just resistors in series with the control signals. See sheet 62 of the datasheet

If you have trouble with SD cards, then look for another adapter that has signal level conversion chips on them.

Ok, thanks.

I can hear your AI code screaming "Put me in a function!!!"

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.