odd character limitation in code

I am having an issue with a what seems to be a character limitation within my code.
My code has 3 steps:

  1. Get reading from a photoresistor and when that reading falls below a defined threshold;
  2. Select a single line of text from a set of 20;
  3. Send that text to an Amplus LED Scrolling Message Display.

It seems that the output to the serial port (and the message board) shows an error when the total number of characters in the char* set exceeds 900. I can’t figure out why this would be. Any suggestions?
(the total number of characters including the formating [spaces, " , ] for that section of code gives an error when it goes over 1000 - ie there are 99 spaces " and , I just throw that in at it seemed like a significant thresehold)

Ed

//Description. 
//Use a photoresistor as a trigger. When the light level goes down beyond a certain point an action is triggered. 
//This action is to randomly select 1 of 20 sentences.
//That sentence is then sent to an Amplus LED Message Board.

#include <BockiMessageBoard.h>
#include <TrueRandom.h>
#include "Arduino.h"
#include <math.h>

BockiMessageBoard messageBoard = BockiMessageBoard(01); // Pass in ID of message board

char* answers[20] = {
  "Text 01 As I",
  "Text 02 As I see aperture looks running a dukes dance",
  "Text 03 As I see it, yes A proposed kisses for running",
  "Text 04 As I see it, yes A proposed kick like rug",
  "Text 05 As I see it a ground and like running long",
  "Text 06 As I see it, yes I go aground and like run",
  "Text 07 A yes like running aground mud",
  "Text 08 aground kit and around",
  "Text 09 I can see it but yet before",
  "Text 10 As I see it, yes A grand land",
  "Text 11 As I see it, yes A ping a round in",
  "Text 12 As I see it, yes A running around and over",
  "Text 13 As I see it, he is running aground",
  "Text 14 As I see it, yes A prop to burn",
  "Text 15 As I see it, no A proposed running agro",
  "Text 16 As I see it, yes A snub or objection means i will",
  "Text 17 As I see it, nobody has objectioned so i will",
  "Text 18 As I see it, yes no As it is there to use is no",
  "Text 19 As I see it, yes A pound as objection will",
  "Text 20 As I see it, no objection will"
};

const int analogPin = A0;    // pin that the sensor is attached to. This is the switch
const int ledPin = 13;       // pin that the LED is attached to
const int threshold = 300;   // a threshold level that's in the range of the analog input

int answerNumber;

void setup()
{
  pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:

  Serial.flush();   // flush serial port:
  Serial.begin(9600);   // initialize serial communications:

  int displayTime = 0.5; // Input 0.5 sec or 1 to 25 seconds. This pauses the text on the screen.

  messageBoard.configure(displayTime,SCROLLLEFT,SCROLLLEFT); //Animation types: IMMEDIATE, CURTAINUP, CURTAINDOWN, SCROLLLEFT, SCROLLRIGHT, VERTICALOPEN, VERTICALCLOSE, SCROLLUP, SCROLLDOWN, HOLD, SNOW, TWINKLE, BLOCKMOVE
}

void loop()
{

  int analogValue = analogRead(analogPin);  // read the value of the photosensor:
  delay(500);  // delay in between reads for stability

  if (analogValue < threshold) {  // if the analog value is low enough, turn on the LED:
    digitalWrite(ledPin, HIGH);

    answerNumber = TrueRandom.random(20);

    messageBoard.displayMessage(PAGE_A, answers[answerNumber] ); // Page id PAGE_A - PAGE_Z and message of choice
    delay(1000);
  }

  else 
  {
    digitalWrite(ledPin,LOW); 
  }

}

You're almost certainly running out of RAM. Try putting your constant strings in PROGMEM.

Thanks AWOL.I'm not sure how to but I'll look at some tutorials and give it a go. Ed

answers[] needs to be declared with two dimensions. I always get the order mixed up. One dimension holds the text string, the other is the lines.

try char answers[20][]

answers[] needs to be declared with two dimensions.

It's an array of char pointers.

EdRover: Thanks AWOL.I'm not sure how to but I'll look at some tutorials and give it a go. Ed

http://www.gammon.com.au/forum/?id=12153#tip2

AWOL:

answers[] needs to be declared with two dimensions.

It's an array of char pointers.

Oh. I see. I'm going to have to play with that. Looks handy and I can always use the practice with pointers.