use an array in another function


I declared and stored an array in a function and I want to use it in another function but I have only the last value of the array which has the good value the other are zero.

#include <avr/io.h>
#include <avr/interrupt.h>
#define N 50
short i=0;
float Tech=5000 ;
void setup()
cli(); // disable global interrupts

TCCR1A = 0; // set entire TCCR1A register to 0
TCCR1B = 0; // same for TCCR1B

OCR1A = 16000*Tech/64; // set compare match register to desired timer count. 16 MHz with 1024 prescaler = 15624 counts/s
TCCR1B |= (1 << WGM12); // turn on CTC mode. clear timer on compare match

TCCR1B |= (1 << CS10); // Set CS10 and CS11 bits for 64 prescaler
TCCR1B |= (1 << CS11);

TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt

sei(); // enable global interrupts}
if (i<N)

void loop()

void FillArray(float TheArray)
//for(int p = 0; p < N; p++)
void test()
float MyArray[N]={0};
short val=analogRead(A0);
_ Serial.println(MyArray*);*_

* if(i==N-1)*
* {*
* FillArray(MyArray);*
* }*
*i++; *

. . . and that's why we ask you to use code tags when posting code.

You can't (or rather, you shouldn't) be doing Serial.print() in an interrupt service routine.

In the microcontroller world, arrays are big things. So big you don't ever want to move them.

char MyCharArray[]= "The quick brown fox jumped over the lazy dog.";

void setup() {
void loop() {

In this example, the long string isn't copied to the println() function. The code just tells println() where it is and "go print that for me please."

For your array-manipulating functions, you should be passing the address of the array (the variable with the array's name) so that the function can work with that location instead of a copy of the data. This is why you also need to send the size of the array or have it stored somewhere else. The address of the data doesn't include any information on length.