How to "remove" int from a list each interaction? -drink roulette

Hi to all… Im making a drink roulette, and I like to add some features at just turn and drink.

You can see the progress in here(Spanish)

The classic roulette turns and stops in any given time, but I want to make this to have the next feature;

Once is loaded, say 12 glasses, start… and stop lets say at 8 position.

So the next I want to make is to make the available random = {1…12} -8
I mean the position, so… if the glass with the drink number 8 has been taken… it will not be available for the next itereation…
So lets say…
Random = 8 //past shot
if random = (used spaces){
random again}
else random;

So… I let my code in here;

#include <Stepper.h>

const byte noise = A0; 
const byte led = 13;

byte reverse_direction = 0; 
int  analog_seed; 
int  random_number = 0; 
int  motor_number = 0; 

boolean changue = false;                           //var to changue direction of stepper

const int stepsPerRevolution = 48;                 //steps per revolution
Stepper myStepper(stepsPerRevolution, 8,9,10,11);  //Pins to the stepper 

void setup(){
  pinMode(led, OUTPUT);     

void loop(){
  if(Serial.available() > 0){
    if(Serial.peek() == 'c'){  //chek for c to start code 

      Serial.print("El paso del motor es   "); Serial.println(motor_number);      
      digitalWrite(led, HIGH); 


int get_number_steps(){
    analog_seed =  analogRead(noise); //gets a value between 0 and 1023
    random_number = random(0,12); 
    Serial.print("The aleatory number is "); Serial.println(random_number); 
    motor_number = map(random_number, 0, 12, 0, 48); 
 return motor_number; 

int switch_direction(){
  if (changue == false){
     Serial.println("to the rigth ");
     changue = true; 
     return motor_number;  
  if(changue == true){
     Serial.println("To the left ");
     changue = false; 
     motor_number =(motor_number) * ( -1); 
     return motor_number; 

I was thinking to use an bidimensional array

drinks [12][12]= {1,2,3,4,5,6,7,8,9,10,11,12}
{0,0,0,0,0,0,0,0,0, 0, 0, 0}

And let say …

random = random_number
//look for it on the array
if random_number == true{
//use for stepper
random_number = false; }

if random_number == false {
random() //again ???

Or more clearly how to discount an already used option from an array or a list.

If any one have any ideas, or the precise name for what I intent to do, please share, I will investigate… is for a good cause… a drinks roulette 8)

Thanks !

Give this a look at. Its a random number generator that produces a random number from a given set and it only gives a number that was not previously given.

It works great for small ranges but its not ideal for large ranges like 0 - 10000.

int randNumber;
#define Count 10
int list[Count];
byte i = 0;
boolean found = false;

void setup()
  for (byte K = 0; K < 5; K++)
    for (int j = 0; j < Count; j++)
      list[j] = -1;

    randomSeed(K + 1);
    i = 0;
    found = false;
    while (i < Count)
      randNumber = random(0, Count);
      for (byte L = 0; L < i; L++)
        found = false;
        if (list[L] == randNumber)
          found = true;
      if (!found)
        list[i] = randNumber;

void loop() {

HazardsMind: Give this a look at. Its a random number generator that produces a random number from a given set and it only gives a number that was not previously given.

Thanks a lot!!! I will read carefully !!! Will comeback with advances! :sunglasses:


Look up a "shuffle" algorithm.

Using that is like "shuffling" the drinks, and afterwards you get one at random.

for small numbers your array is good as it will need about 11 numbers to find a free one when bigger it is better to use a swap mechanism you have a big array 1000 places. the content is int from 1 to 1000 random says 234 now swap place of 234 and 1000 use the 234 so array[234] is 1000 and array [1000] =234 next random number is max 999 example 345 swap with 999 so array [345] is 999 and array [999]= 345 next random is max 998 etc. when max is 1 all are done, you have an array full with all numbers in reversed sequence. just reset the counter and start with a random array and put a second random

wow... in three responses and there is more than plenty to work with!

Thanks to all you!

I will give my self some time to read the different approaches, and will come back with something to discuss..

Again.. Thank you!