Skip to main content
deleted 25 characters in body; edited title; edited body
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

error Error array value after passed to a function

iI would like to asask about "weirdness"a weirdness in my program, this. This is my program:

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

void loop()
  {
   workout_Text();
}

void workout_Text() {
  int woT_x[] = {1, 4, 8, 12, 16};
  int woT_y[] = {1, 4, 8, 12, 16};
  int n = sizeof(woT_y);
  on_led(woT_x, woT_y, n);
}
 

void on_led(int a_mat[], int b_mat[], int m) {
  for (int i = 0; i < m; i++) {
 
    Serial.print(a_mat[i]);
    Serial.print(" : ");
    Serial.println(b_mat[i]);
 
    delay(100);
  }
} 

thisThis is the part of my program for leda LED matrix, the. The on_led purpose function on_led purpose is for printing the value of a_mata_mat and b_mat, insteadb_mat. Instead of printing:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
1 : 1
4 : 4
8 : 8
16 : 16

itIt prints:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
13312 : 1
23296 : 4
1 : 8
4 : 12
8 : 16
1 : 1
4 : 4
8 : 8

whereWhere does the big number come from? iI am sure that my code is right to just print the a_mata_mat and b_mat thankb_mat.

Thank you.

error array value after passed to a function

i would like to as about "weirdness" in my program, this is my program

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

void loop()
 {
   workout_Text();
}

void workout_Text() {
  int woT_x[] = {1, 4, 8, 12, 16};
  int woT_y[] = {1, 4, 8, 12, 16};
  int n = sizeof(woT_y);
  on_led(woT_x, woT_y, n);
}
 

void on_led(int a_mat[], int b_mat[], int m) {
  for (int i = 0; i < m; i++) {
 
    Serial.print(a_mat[i]);
    Serial.print(" : ");
    Serial.println(b_mat[i]);
 
    delay(100);
  }
} 

this is the part of my program for led matrix, the function on_led purpose is for printing the value of a_mat and b_mat, instead of printing

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
1 : 1
4 : 4
8 : 8
16 : 16

it prints

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
13312 : 1
23296 : 4
1 : 8
4 : 12
8 : 16
1 : 1
4 : 4
8 : 8

where does the big number come from? i am sure that my code is right to just print the a_mat and b_mat thank you

Error array value after passed to a function

I would like to ask about a weirdness in my program. This is my program:

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

void loop() {
   workout_Text();
}

void workout_Text() {
  int woT_x[] = {1, 4, 8, 12, 16};
  int woT_y[] = {1, 4, 8, 12, 16};
  int n = sizeof(woT_y);
  on_led(woT_x, woT_y, n);
}

void on_led(int a_mat[], int b_mat[], int m) {
  for (int i = 0; i < m; i++) {
    Serial.print(a_mat[i]);
    Serial.print(" : ");
    Serial.println(b_mat[i]);
    delay(100);
  }
} 

This is the part of my program for a LED matrix. The on_led purpose function is for printing the value of a_mat and b_mat. Instead of printing:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
1 : 1
4 : 4
8 : 8
16 : 16

It prints:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
13312 : 1
23296 : 4
1 : 8
4 : 12
8 : 16
1 : 1
4 : 4
8 : 8

Where does the big number come from? I am sure that my code is right to just print the a_mat and b_mat.

Thank you.

Source Link
Zahi Azmi
  • 139
  • 1
  • 9

error array value after passed to a function

i would like to as about "weirdness" in my program, this is my program

void setup()
{

 Serial.begin(9600);
}

void loop()
{
   workout_Text();
}

void workout_Text() {
  int woT_x[] = {1, 4, 8, 12, 16};
  int woT_y[] = {1, 4, 8, 12, 16};
  int n = sizeof(woT_y);
  on_led(woT_x, woT_y, n);
}


void on_led(int a_mat[], int b_mat[], int m) {
  for (int i = 0; i < m; i++) {

    Serial.print(a_mat[i]);
    Serial.print(" : ");
    Serial.println(b_mat[i]);

    delay(100);
  }
} 

this is the part of my program for led matrix, the function on_led purpose is for printing the value of a_mat and b_mat, instead of printing

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
1 : 1
4 : 4
8 : 8
16 : 16

it prints

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
13312 : 1
23296 : 4
1 : 8
4 : 12
8 : 16
1 : 1
4 : 4
8 : 8

where does the big number come from? i am sure that my code is right to just print the a_mat and b_mat thank you