in the past, this bit of code in void setup() played back one of 15 audio files in my audio files root directory on bootup:
pinMode(A0, INPUT ); randomSeed(analogRead(A0));
sendCommand(CMD_PLAY_W_INDEX, 0X030000 + random(1, 15)); // play on reset 1 of 15 files in root folder
then it stopped working. now it plays file 1 or 8 only.
this random number test program:
void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT ); randomSeed(analogRead(A0));
}
void loop()
{
int c; c = random(1, 15); Serial.print(c); delay(1000); Serial.println();
}
produces this result:
8
14
9
6
2
7
4
10
5
3
4
12
4
3
7
9
11
5
14
12
14
this change, to reflect the way my void setup works:
void setup()
{
Serial.begin(9600);
}
void loop()
{
pinMode(A0, INPUT ); randomSeed(analogRead(A0));
int c; c = random(1, 15); Serial.print(c); delay(1000); Serial.println();
}
produces:
1
8
8
8
8
1
1
1
8
1
1
8
8
1
8
8
1
8
8
1
8
8
what is happening, to make random seed generate the same two numbers?