Buzzword generator

Buzzword bingo is everyone's favourite game, right? So as a way of making it a little more fun I want to produce a random buzzword from a list then the player has to slip it into a meeting whilst keeping a straight face. What better way to use your arduino? Probably loads but hey ho.

So the problem is I'm a bit useless at this. the approach I'm taking is to generate a random number then to use that number to look up in an array and to pick fro a list of phrase's. I'm struggling to keep the monkey's under the table here. Is this a good approach?

So far I've got my head round generating a random number using an analogue pin and can prove that. Code below...

long randNumber;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


//buzz buzzArray[]={a, b, c, d};

void setup(){
  lcd.begin(16,2);
  randomSeed(analogRead(1));
  lcd.print("Wait for it.....");
  delay(3000);
  lcd.clear();
  lcd.print("I'm thinking....");
  delay(3000);
  lcd.clear();
  lcd.print("Your challenge..");
  delay(2000);
}

void loop(){
  randNumber = random(20);
  lcd.setCursor(0,0);
  lcd.print("Your random no..");
  lcd.setCursor(6,1);
  lcd.print(randNumber);
  delay(5000);
  lcd.clear();
}

Next up is the lookup in an array. Before I draw a line in that sand can anyone confirm that this is a sound approach before I try and work out what these array's do? After that it'll be a mess about with the code and use a big button to do the generation rather than the current format.

The follow on from that question then is it normal to use a number (index?) to return a value from an array?

Just running this up the flagpole :wink:

Buzzword bingo is everyone's favourite game, right?

Wrong.

Before I draw a line in that sand can anyone confirm that this is a sound approach before I try and work out what these array's do?

It is.

After that it'll be a mess about with the code and use a big button to do the generation

To trigger, not to do. Big buttons are hardly suitable for generating random numbers.

The follow on from that question then is it normal to use a number (index?) to return a value from an array?

It is normal to use a number as an index into an array. What you do with the indexed value is a separate issue.

Sounds about right :slight_smile:

But be sure to place that array in PROGMEM. Which is not that straight forward... Otherwise you will run out of memory pretty quick.

Alternatively use a SD-card. That way it's even possible to update the list without reprogramming it. Just make a text file (.txt) with all the words, each on a new line. At the start go trough the whole list to count how many words there are (by looping over all chars and counting the new lines). Now you can use random to pick a word. And to fetch the word, you go over the file and count that number of new lines. (A new line is just a character so the Arduino has no notion of line numbers by itself.)

Two extra points:

  • Add a button (bonus tip: a library like Bounce2 makes it dead easy) to generate a new word instead of resetting the Arduino. Although the reset is indeed a pretty easy solution as well :stuck_out_tongue:
  • Even though you only use A1 to generate a random seed, use a constant for that as well. That way it's easy to sport at the top you already "used" that pin.
const byte RandomPin = A1;

void setup(){
  randomSeed(analogRead(RandomPin));
}

Cheers guys, I like the idea of the sd card. It'll make life a shed load easier. Always good when you stir fry ideas in the strategy wok....:wink:

Good to know I'm on the right lines. A bit more reading to do

Thanks

Alex