I need help with counting the occurrence of random numbers.

Hello, I need help finishing this project. The project is suppose to generate a specific amount of numbers between a specific range of numbers. I chose 100 numbers between the range from 0 to 10.

Here is the code, Thanks.

int numStart = 0;
int numEnd =100;
int summa;
int randNumber;
int numero0 = 0;
int numero1 = 1;
int numero2 = 2;
int numero3 = 3;
int numero4 = 4;
int numero5 = 5;
int numero6 = 6;
int numero7 = 7;
int numero8 = 8;
int numero9 = 9;
int numero10 = 10;

void setup() {
Serial.begin(9600);
}

void loop() {
if (summa = summa + 1) {
randNumber = random(10);
}
if (numStart != numEnd) {
numStart++;
summa = summa + numStart;
if (randNumber = 0) {
numero0++;
Serial.println("Numero_0");
Serial.println(numero0);
delay(1000);
}
if (randNumber = 1) {
numero1++;
Serial.println("Numero_1");
Serial.println(numero1);
delay(1000);
}
if (randNumber = 2) {
numero2++;
Serial.println("Numero_2");
Serial.println(numero2);
delay(1000);
}
if (randNumber = 3) {
numero3++;
Serial.println("Numero_3");
Serial.println(numero3);
delay(1000);
}
if (randNumber = 4) {
numero4++;
Serial.println("Numero_4");
Serial.println(numero4);
delay(1000);
}
if (randNumber = 5) {
numero5++;
Serial.println("Numero_5");
Serial.println(numero5);
delay(1000);
}
if (randNumber = 6) {
numero6++;
Serial.println("Numero_6");
Serial.println(numero6);
delay(1000);
}
if (randNumber = 7) {
numero7++;
Serial.println("Numero_7");
Serial.println(numero7);
delay(1000);
}
if (randNumber = 8) {
numero8++;
Serial.println("Numero_8");
Serial.println(numero8);
delay(1000);
}
if (randNumber = 9) {
numero9++;
Serial.println("Numero_9");
Serial.println(numero9);
delay(1000);
}
if (randNumber = 10) {
numero10++;
Serial.println("Numero_10");
Serial.println(numero10);
delay(1000);
}

Serial.print(randNumber);
delay(1000);
}
}

  if (summa = summa + 1)

Except for when summa is equal to -1, that conditional will always be true.

if (randNumber = 0) {That conditional will always be false.

Did you have a question?

Please remember to use code tags when posting code.

Look to all your if()s, = is not the same as == and you look to be using the wrong one (unless you're trying to do something clever that I don't understand).

Steve

I got this working, Thanks for the help.

Much shorter solution:

int count[10];

void loop() {
  randNumber = random(10);
  count[randNumber]++;
  Serial.print("Numero_");
  Serial.print(i);
  Serial.print(": ");
  Serial.println(count[randNumber]);
  delay(1000);
}

Note: random(10) will return a value 0-9, the maximum limit is exclusive.