If it is important for a sequence of numbers generated by random() to differ, it is a good idea to specify a seed with randomSeed():
void setup() {
Serial.begin(9600);
// If analog pin 0 is left unconnected, analogRead(0) will produce a
// different random number each time the ...