Want to tweet a random preset phrase, but how?


Thanks in advance for the help.

I decided to try and make the "Kitty Twitter" box that was featured in Make Magazine #22. My friends have 4 cats, so I figured it would be a neat gift.

One problem I ran into immediately was that the Twitter Library doesn't compile in versions of the Arduino environment after 018. Trying to include the Ethernet library didn't work, including the SPI library didn't work, but everything seems to compile just fine in the 018 environment.

In the kitty twitter project, the tweets are generated by using the string library to assemble a tweet from a random selection from 3 groups of words. I can't do that because it looks like the string library is no longer available for download since it's now included (??) in versions of the Arduino environment starting with 019.

What I'd rather do is create a set of phrases, have the program randomly select one of those phrases, and tweet that. Actually, I don't even care if it's random. It can go through each message sequentially, just so long as it doesn't try to post the same thing twice (not allowed by Twitter, so far as I can tell).

So, something like

msg 1 = "message 1" msg 2 = "message 2" .... msg 50 = "message 50"

I'd like to have my program somehow select one of those (msg 1 thru 50) and use it in the twitter.post(msg[sequential or random]). I can't figure out how to do that.


How can I write a program that will select a random (or sequential) preset phrase to post to twitter upon a trigger?

Why isn't the string library available for download anymore? Does no one use older versions (before 019) of the environment?

Why doesn't the twitter library (the example "simple post" won't even compile) work in environments after 018?

Thanks again. Let me know if I need to be more specific.

http://arduino.cc/en/uploads/Tutorial/String.zip for WString.h

Thanks for the link to the string library. Perhaps I can use that to append a random number (between 1 and 50) to the word "msg" and use that to tweet?

I've tried saying "twitter.post(msg[randomnum])" but the error I get still tells me that I haven't defined "msg". Ideally, I'd get a number, somehow tack it onto the variable "msg" so that I'd have one of the phrases I've already defined. Something like:

char msg1 = ("message 1"); ..... char msg50 = ("message 50");

randomnum = random(50); twitter.post(msg[randomnum]);

After picking a random number, wouldn't it be able to "append" that random number to msg, thus tweeting one of the 50 preset messages? From what I've seen, no. Why not? Am I switching variable types?

Semi-related: what's the difference between char and char* ?

Thanks again everyone.

You could create a two dimensional array of characters, but, you can't dynamically define the name of the array, and expect to do anything with it's address.

Or create an array of strings, and define an index (randomly) into that array.