Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

MSP430 simple number generator

$
0
0

I was trying to use the rand() function but it seems not to be able to run without being in debug and stepping through my program so I was wondering if anyone has a simple way to generate a number from 0-5 below is what i was trying to do.

 

int number (){
  srand ( time(NULL) ); //initialize the random seed
 
 
 
  int RandIndex = rand() % 6; //generates a random number between 0 and 5
 numbers = RandIndex;
 return numbers;
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles