Better to have all tasks handled by Arduino or combine with Processing?

I want to do the following.

  1. Use a photoresistor as a trigger. When the light level goes down beyond a certain point an action is triggered.
  2. The action is to randomly select 1 of 50 sentences. The sentences are between 6 and 35 words long.
  3. That sentence is then sent to an Amplus LED Message Board. (using a sketch modified from the BockiMessageBoard library)

My question is - would I be better trying to do all this with a single sketch with the Arduino or better to have 'Processing' handle the random selection of the texts and feed this back to the Arduino to then send on to the LED Message Board?

Any thoughts?

Thanks

Ed

The sentences are between 6 and 35 words long.

Well, now we know how much memory they'll occupy. Ummm, no we don't.

There is nothing challenging in what you want to do, assuming you already know how to send messages to the LED message board. The only question is whether you have enough memory. PROGMEM may be useful, if the messages are static.

The deciding factor in my mind is where the text messages will be defined and stored. If they can be hard-coded in the sketch then you can do all you're asking for very easily entirely within the Arduino.

If they need to be configurable then you need to decide how easily they need to be configurable. One option would be to save the messages in a text file on a connected PC and have the Arduino read from that text file. If the PC is running Windows then this could be done very easily using Gobetwino. In that case when you want a new message read in the whole file line by line to count how many lines there are, then select a line number at random and display the content of that line. If it is unable to read from the file then use the same message used last time, and have that message initialised with a hard-coded value so that your solution displays something sensible (and recognisable) if it hasn't managed to read a message at all.

Paul, thanks, I do already know how to send to the LED message board. So, yes, the issue is indeed is there sufficient memory.
I put the length of the sentences as I thought this would give an indication of the amount of data that needed to be stored and retrieved but you seem to be suggesting that is not that case?
I'll try PROGMEM - that would basically mean that the text would be stored in flash memory and everything else in SRAM, right? That would seem sensible - thanks.
Ed

Peter, I think that the text can be hard coded into the sketch. That is the approach I was intending to take if the opinion was that all of this could be handled by the arduino rather than sharing the tasks between the arduino and a computer. I'm using a mac so Gobetwino is not an option.
Ed

Ed, the problem is that "word" is not precise. How many characters in each of your 50 sentances, including spaces and other punctuations?

Paul (there are too many Pauls on this board...)

And there are sneaky ways of compression, such as making an array of words and coding messages as strings of indexes into that word array.

Another Paul.

The sketch itself would be quite simple which implies that the code will not be very big - you are likely to have most of your PROGMEM available to hold hard-coded text messages. Fifty messages of up to fifty characters each would be a realistic budget - is that likely to be enough? If not, consider using SD storage for the messages. You can get Arduinos with integral SD slots, and it's not expensive to get an SD shield if you have a standard Arduino without one.

Ah, I see, yes, 'words' is to imprecise. I haven't finalised the text yet so I was estimating the numbers. I would estimate there would be around 9000 characters which from PeterH's comments would suggest that I'd be better to have these on an SD card with an SD Shield???
(I'm using an Uno with an Ethernet Shield)

Paul_B - regarding the 'sneaky ways of compression'. It sounds complicated - beyond a newbie?

Ed

For some reason my mental arithmetic in the previous post was off by an order of magnitude.

In a 328-based Arduino you have about 32KB of program memory space of which a few KB will be taken up by your sketch - we don't know exactly how much yet. Even if you end up with 10KB of code - which is quite a generous estimate - that still leaves you enough space for about 20KB of text.

EdRover:
regarding the 'sneaky ways of compression'. It sounds complicated - beyond a newbie?

Actually, it isn't all that hard. You can define macros (if the IDE has that functionality) whose labels are the words themselves and whose value is the index to that word in the word array and just string them together as if they were those same words.

It is likely that you will have less than 256 actual words, in which case the array indexes could be reduced to byte values, so the compressed text contains one byte per word. More generally two bytes per word - and there are very few two letter words.

It seems to me, the key question you didn't ask, do you want this device to operate indepdently of having a working
PC connected to it, all of the time ?

michinyon - I have an old computer I could deploy for this but if it can run efficiently without then I might as well run without.

Paul_B - thanks for expanding. I think I understand but I think that for the moment, applying it is beyond me.