Thank Johnwasser !
It works fine except when I loop.
After 6 loops, I find myself with the same number.
(Random1 = 25, Random2 = 22, Random3 = 23, Random4 = 33, Random5 = 21, Random6 = 35)
(Random1 = 33, Random2 = 35, Random3 = 34, Random4 = 34, Random5 = 24, Random6 = 26)
(Random1 = 34, Random2 = 26, Random3 = 35, Random4 = 26, Random5 = 34, Random6 = 24)
(Random1 = 34, Random2 = 35, Random3 = 35, Random4 = 24, Random5 = 35, Random6 = 26)
(Random1 = 35, Random2 = 26, Random3 = 35, Random4 = 35, Random5 = 24, Random6 = 24)
(Random1 = 35, Random2 = 35, Random3 = 35, Random4 = 35, Random5 = 35, Random6 = 35)
Here is my code :
const int number = 6;
int myH1[] = {21, 22, 23, 24, 25, 26, 33, 34, 35};
const int intervalleTemps = 4000;
void select() {
int count = sizeof myH1 / sizeof myH1[0];
Serial.print("(");
for (int i = 0; i < number; i++) {
int index = random(count); // Random integer from 0 to count-1
Serial.print("Random");
Serial.print(i+1);
Serial.print(" = ");
Serial.print(myH1[index]);
if (i==number-1) // If last value
Serial.println(")");
else
Serial.print(", ");
myH1[index] = myH1[count-1];
count--;
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
select();
delay(intervalleTemps);
}