Bingo number generator


hi, i'm trying create bingo generator, keep getting duplicated numbers, here code

#include <liquidcrystal.h>
liquidcrystal lcd(12, 11, 5, 4, 3, 2);

const int switchpin = 6;
int switchstate = 0;
int prevswitchstate = 0;
long randnumber;

void setup(){
  lcd.begin(16, 2);
  pinmode(switchpin, input);
  randomseed(analogread(0));
 
  lcd.print("bingo");
  lcd.setcursor(0, 1);
  lcd.print("good luck!");
}

void loop(){
  switchstate = digitalread(switchpin);
 
  if (switchstate != prevswitchstate) {
    if (switchstate == low) {
      randnumber = random(91);
 lcd.clear();
lcd.setcursor(0, 0);
lcd.print("number is:");
lcd.setcursor(0,1);
      lcd.print(randnumber);
    }
  }
prevswitchstate = switchstate;
}

what code should add number generated isn't repeated?

thank in advance

create array , initialise zeros. when have selected random number check new array. if 0 set 1 , display number. if 1 (ie, selected) pick number.

incorporate while loop?


Arduino Forum > General Category > General Discussion (Moderators: mbanzi, DojoDave, mellis) > Bingo number generator


arduino

Comments