Turn a list into anything that can be compared (string, float, int, etc.)

void loop(){ 

int SerieNumber[]  = {1,1,1,1,1,1};       // ATTENTION! This is the two lists that is being changed.
int SerieNumber_[] = {1,1,1,1,1,1};    

  int Difficulty = analogRead(Pot) / 204.6 + 1; LedReset();
  
if (Difficulty  > 0) {digitalWrite(Led[8], HIGH);}
if (Difficulty  > 1) {digitalWrite(Led[7], HIGH); digitalWrite(Led[6], HIGH);}
if (Difficulty  > 2) {digitalWrite(Led[4], HIGH);}
if (Difficulty  > 3) {digitalWrite(Led[3], HIGH); digitalWrite(Led[5], HIGH);}
if (Difficulty  > 4) {digitalWrite(Led[1], HIGH); digitalWrite(Led[2], HIGH);}
if (Difficulty  > 5) {digitalWrite(Led[0], HIGH);}
  
  if (digitalRead(Btn[0]) == HIGH){ LedReset(); delay(500); 
    SerieNumber_[0]=random(0, 4); SerieNumber_[1]=random(0, 4); SerieNumber_[2]=random(0, 4);
    SerieNumber_[3]=random(0, 4); SerieNumber_[4]=random(0, 4); SerieNumber_[5]=random(0, 4);
    
  for (int n = Difficulty; n <= 5; n++) {SerieNumber_[n] = 1;}

  for (int n = 1; n <= Difficulty ; n++){
    if (SerieNumber_[n-1] == 0){LedDisplay_1();delay(300);}
    if (SerieNumber_[n-1] == 1){LedDisplay_2();delay(300);}
    if (SerieNumber_[n-1] == 2){LedDisplay_3();delay(300);}
    if (SerieNumber_[n-1] == 3){LedDisplay_4();delay(300);}}

  for (int n = 1; n <= Difficulty ; n++){ 
    if (digitalRead(Btn[0]) == HIGH) {LedDisplay_1(); SerieNumber[n-1]=0; n++;}
    if (digitalRead(Btn[2]) == HIGH) {LedDisplay_2(); SerieNumber[n-1]=1; n++;}
    if (digitalRead(Btn[1]) == HIGH) {LedDisplay_3(); SerieNumber[n-1]=2; n++;}
    if (digitalRead(Btn[3]) == HIGH) {LedDisplay_4(); SerieNumber[n-1]=3;}
  else n--;}}}

ok guys, above is my code. im not going to explain it that much cause i do not think it is important, i just wanted to include it if you wanted to take a look.

so my problem is, i got two lists, SerieNumber and SerieNumber_. Those two are being changed in the program, depending on what i do.

One of the lists are being changed randomly, and one is changed by the player.

its “remember the order” game where i use an LED display and 4 buttons.

so the problem is, i want to make list into a number.

if i do:

Serial.print("Serie_:"); Serial.print(SerieNumber_[0]); Serial.print(SerieNumber_[1]); Serial.print(SerieNumber_[2]);Serial.print(SerieNumber_[3]);Serial.print(SerieNumber_[4]); Serial.println(SerieNumber_[5]); 
Serial.print("Serie:");  Serial.print(SerieNumber[0]);  Serial.print(SerieNumber[1]);  Serial.print(SerieNumber[2]); Serial.print(SerieNumber[3]); Serial.print(SerieNumber[4]);  Serial.println(SerieNumber[5]);

then i get this as a resoult:

Serie_:023331
Serie:023331

just to take an exsample. now those numbers are printed, but what i want is to turn THAT number, into an int. (or float or whatever… as long as i can compare it)

the deal is to check if Serie: and Serie_: are equal, to check if the player clicked in the correct order.

SIMPLE PROGRAM THAT WILL HELP ME SOULVE THE PROGRAM:

int a = 1
int b = 2
int c = 3
int x =(a,b,c)
// x is equal to 123

i know that code does not make sence, but it gives you an idea. how do i make that x?

use snprintf()

Some suggestions.

  1. Don't bother with the conversion. Loop through the elements of each array and compare them. Once one pair does not match then the player failed.

  2. If you really want numbers to compare then multiply the elements of the array successively by 1, 10, 100, 1000 etc and add them together to make a long variable

  3. Use char arrays instead of int arrays, put a null on the end and use the atol() function to create the number.

  4. Compare the arrays directly using memcmp()

Whatever else you do I would advise changing the name of one or both of the arrays to avoid confusion later.

UKHeliBob: Some suggestions.

  1. Don't bother with the conversion. Loop through the elements of each array and compare them. Once one pair does not match then the player failed.

  2. If you really want numbers to compare then multiply the elements of the array successively by 1, 10, 100, 1000 etc and add them together to make a long variable

  3. Use char arrays instead of int arrays, put a null on the end and use the atol() function to create the number.

  4. Compare the arrays directly using memcmp()

Whatever else you do I would advise changing the name of one or both of the arrays to avoid confusion later.

thank you a lot, but i dont know a lot about the language. sort of new to arduino. can you show exsamples, and codes? and explain them?

again thank you! :)

i dont know a lot about the language.

You'll never learn if you don't, to paraphrase Nike, "Just Do It!".

can you show exsamples, and codes?

Why should we. 15 seconds with google will have all YOU need.

and explain them?

Do you own work, and you will understand it!