Hello guys,
i am measuring the magnetic field with a magnetfieldsensor.
The signal is quite wavy thats why i decided to use the average value of 200 measurements.
The problem is i did that in a for loop and it just works when i print the signal inside the loop (see code). How can i use the value as a global variable and get it outside of the loop?Also this is all in void loop function. i wont put the whole code because its too long... Also the sensor uses i2c communication. I just want the value of "mittelwert" to also be used outside of the loop.
It doesn't work because your variable mittelwert was not declared as a global variable. Your posted snippet is useless because it doesn't show where the declaration of mittelwert took place but I am assuming it was within the loop function.
If your full code is too long to post then please write a short code that illustrates your problem.
Im sorry but i think you misunderstood me... the thing is like this: i have the rms value as you can see. and i want every 200 measurements that the average is calculated (mittelwert). And everything perfectly worked out within the loop. the values i get for mittelwert are good. But when i print mittelwert outside of the loop, it just gives me 0 values. Not the same values as in the loop.